Skip to content

Commit

Permalink
Back out the default 'main' branch change
Browse files Browse the repository at this point in the history
The fix of PR 279 is incomplete, we'd like to discard the change of
the default 'main' branch. If user fetches 'main' branch, a workaround
by specifying the branch 'main' in the git query can be used. e.g.

<fetch url="git://FOO.redhat.com/kernel-tests?main#a/b/c"/>

Signed-off-by: Vector Li <[email protected]>
  • Loading branch information
Vector Li committed Feb 23, 2023
1 parent 9580f65 commit 3a4e0b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
15 changes: 3 additions & 12 deletions src/fetch_git.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include "fetch.h"
#include "fetch_git.h"

static const gchar *g_git_branches[] = {GIT_BRANCHES};

static gint
packet_length(const gchar *linelen)
{
Expand Down Expand Up @@ -232,16 +230,9 @@ myopen(FetchData *fetch_data, GError **error)
"While writing to %s: ", fetch_data->url->host);
goto error;
}

// traverse git branches one by one
for (gint i = 0; i < sizeof (g_git_branches) / sizeof (const gchar *); i++) {
gchar *branch = (gchar *)(g_git_branches[i]);
write_succeeded = packet_write(fetch_data->ostream, &tmp_error, "argument %s:%s\0",
fetch_data->url->query == NULL ? branch: fetch_data->url->query,
fetch_data->url->fragment == NULL ? "" : fetch_data->url->fragment + fragment_offset);
if (write_succeeded)
break;
}
write_succeeded = packet_write(fetch_data->ostream, &tmp_error, "argument %s:%s\0",
fetch_data->url->query == NULL ? GIT_BRANCH : fetch_data->url->query,
fetch_data->url->fragment == NULL ? "" : fetch_data->url->fragment + fragment_offset);
if (!write_succeeded) {
g_propagate_prefixed_error(error, tmp_error,
"While writing to %s: ", fetch_data->url->host);
Expand Down
7 changes: 1 addition & 6 deletions src/fetch_git.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,8 @@
#ifndef _RESTRAINT_FETCH_GIT_H
#define _RESTRAINT_FETCH_GIT_H

/*
* The main branch ("main") is fetched by default, but we also support to
* fetch the legacy one (i.e. "master") because it is required by some old
* repositories.
*/
#define GIT_BRANCHES "main", "master"
#define GIT_PORT 9418
#define GIT_BRANCH "master"
#define HDR_LEN_SIZE 4

#include <libsoup/soup.h>
Expand Down

0 comments on commit 3a4e0b4

Please sign in to comment.