Skip to content

Commit

Permalink
Merge branch 'maint-1.7.11' into maint
Browse files Browse the repository at this point in the history
  • Loading branch information
Junio C Hamano committed Sep 12, 2012
2 parents cbd6b08 + 1403db4 commit 3503e9a
Show file tree
Hide file tree
Showing 19 changed files with 321 additions and 162 deletions.
6 changes: 3 additions & 3 deletions Documentation/git-checkout.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ entries; instead, unmerged entries are ignored.
When checking out paths from the index, check out stage #2
('ours') or #3 ('theirs') for unmerged paths.

-b::
-b <new_branch>::
Create a new branch named <new_branch> and start it at
<start_point>; see linkgit:git-branch[1] for details.

-B::
-B <new_branch>::
Creates the branch <new_branch> and start it at <start_point>;
if it already exists, then reset it to <start_point>. This is
equivalent to running "git branch" with "-f"; see
Expand Down Expand Up @@ -124,7 +124,7 @@ explicitly give a name with '-b' in such a case.
<commit> is not a branch name. See the "DETACHED HEAD" section
below for details.

--orphan::
--orphan <new_branch>::
Create a new 'orphan' branch, named <new_branch>, started from
<start_point> and switch to it. The first commit made on this
new branch will have no parents and it will be the root of a new
Expand Down
7 changes: 7 additions & 0 deletions Documentation/revisions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ of 'r1' and 'r2' and is defined as
It is the set of commits that are reachable from either one of
'r1' or 'r2' but not from both.

In these two shorthands, you can omit one end and let it default to HEAD.
For example, 'origin..' is a shorthand for 'origin..HEAD' and asks "What
did I do since I forked from the origin branch?" Similarly, '..origin'
is a shorthand for 'HEAD..origin' and asks "What did the origin do since
I forked from them?" Note that '..' would mean 'HEAD..HEAD' which is an
empty range that is both reachable and unreachable from HEAD.

Two other shorthands for naming a set that is formed by a commit
and its parent commits exist. The 'r1{caret}@' notation means all
parents of 'r1'. 'r1{caret}!' includes commit 'r1' but excludes
Expand Down
68 changes: 43 additions & 25 deletions builtin/apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,15 +1095,23 @@ static int gitdiff_unrecognized(const char *line, struct patch *patch)
return -1;
}

static const char *stop_at_slash(const char *line, int llen)
/*
* Skip p_value leading components from "line"; as we do not accept
* absolute paths, return NULL in that case.
*/
static const char *skip_tree_prefix(const char *line, int llen)
{
int nslash = p_value;
int nslash;
int i;

if (!p_value)
return (llen && line[0] == '/') ? NULL : line;

nslash = p_value;
for (i = 0; i < llen; i++) {
int ch = line[i];
if (ch == '/' && --nslash <= 0)
return &line[i];
return (i == 0) ? NULL : &line[i + 1];
}
return NULL;
}
Expand Down Expand Up @@ -1133,12 +1141,11 @@ static char *git_header_name(const char *line, int llen)
if (unquote_c_style(&first, line, &second))
goto free_and_fail1;

/* advance to the first slash */
cp = stop_at_slash(first.buf, first.len);
/* we do not accept absolute paths */
if (!cp || cp == first.buf)
/* strip the a/b prefix including trailing slash */
cp = skip_tree_prefix(first.buf, first.len);
if (!cp)
goto free_and_fail1;
strbuf_remove(&first, 0, cp + 1 - first.buf);
strbuf_remove(&first, 0, cp - first.buf);

/*
* second points at one past closing dq of name.
Expand All @@ -1152,22 +1159,21 @@ static char *git_header_name(const char *line, int llen)
if (*second == '"') {
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail1;
cp = stop_at_slash(sp.buf, sp.len);
if (!cp || cp == sp.buf)
cp = skip_tree_prefix(sp.buf, sp.len);
if (!cp)
goto free_and_fail1;
/* They must match, otherwise ignore */
if (strcmp(cp + 1, first.buf))
if (strcmp(cp, first.buf))
goto free_and_fail1;
strbuf_release(&sp);
return strbuf_detach(&first, NULL);
}

/* unquoted second */
cp = stop_at_slash(second, line + llen - second);
if (!cp || cp == second)
cp = skip_tree_prefix(second, line + llen - second);
if (!cp)
goto free_and_fail1;
cp++;
if (line + llen - cp != first.len + 1 ||
if (line + llen - cp != first.len ||
memcmp(first.buf, cp, first.len))
goto free_and_fail1;
return strbuf_detach(&first, NULL);
Expand All @@ -1179,10 +1185,9 @@ static char *git_header_name(const char *line, int llen)
}

/* unquoted first name */
name = stop_at_slash(line, llen);
if (!name || name == line)
name = skip_tree_prefix(line, llen);
if (!name)
return NULL;
name++;

/*
* since the first name is unquoted, a dq if exists must be
Expand All @@ -1196,10 +1201,9 @@ static char *git_header_name(const char *line, int llen)
if (unquote_c_style(&sp, second, NULL))
goto free_and_fail2;

np = stop_at_slash(sp.buf, sp.len);
if (!np || np == sp.buf)
np = skip_tree_prefix(sp.buf, sp.len);
if (!np)
goto free_and_fail2;
np++;

len = sp.buf + sp.len - np;
if (len < second - name &&
Expand Down Expand Up @@ -1231,13 +1235,27 @@ static char *git_header_name(const char *line, int llen)
case '\n':
return NULL;
case '\t': case ' ':
second = stop_at_slash(name + len, line_len - len);
/*
* Is this the separator between the preimage
* and the postimage pathname? Again, we are
* only interested in the case where there is
* no rename, as this is only to set def_name
* and a rename patch has the names elsewhere
* in an unambiguous form.
*/
if (!name[len + 1])
return NULL; /* no postimage name */
second = skip_tree_prefix(name + len + 1,
line_len - (len + 1));
if (!second)
return NULL;
second++;
if (second[len] == '\n' && !strncmp(name, second, len)) {
/*
* Does len bytes starting at "name" and "second"
* (that are separated by one HT or SP we just
* found) exactly match?
*/
if (second[len] == '\n' && !strncmp(name, second, len))
return xmemdupz(name, len);
}
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion builtin/for-each-ref.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,7 +962,9 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
if (!arg) /* should --no-sort void the list ? */
return -1;

*sort_tail = s = xcalloc(1, sizeof(*s));
s = xcalloc(1, sizeof(*s));
s->next = *sort_tail;
*sort_tail = s;

if (*arg == '-') {
s->reverse = 1;
Expand Down
16 changes: 14 additions & 2 deletions builtin/rev-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ static int try_difference(const char *arg)
const char *next;
const char *this;
int symmetric;
static const char head_by_default[] = "HEAD";

if (!(dotdot = strstr(arg, "..")))
return 0;
Expand All @@ -241,9 +242,20 @@ static int try_difference(const char *arg)
next += symmetric;

if (!*next)
next = "HEAD";
next = head_by_default;
if (dotdot == arg)
this = "HEAD";
this = head_by_default;

if (this == head_by_default && next == head_by_default &&
!symmetric) {
/*
* Just ".."? That is not a range but the
* pathspec for the parent directory.
*/
*dotdot = '.';
return 0;
}

if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
show_rev(NORMAL, end, next);
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
Expand Down
55 changes: 30 additions & 25 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,35 @@ char *get_remote_object_url(const char *url, const char *hex,
return strbuf_detach(&buf, NULL);
}

int handle_curl_result(struct active_request_slot *slot)
{
struct slot_results *results = slot->results;

if (results->curl_result == CURLE_OK) {
credential_approve(&http_auth);
return HTTP_OK;
} else if (missing_target(results))
return HTTP_MISSING_TARGET;
else if (results->http_code == 401) {
if (http_auth.username && http_auth.password) {
credential_reject(&http_auth);
return HTTP_NOAUTH;
} else {
credential_fill(&http_auth);
init_curl_http_auth(slot->curl);
return HTTP_REAUTH;
}
} else {
#if LIBCURL_VERSION_NUM >= 0x070c00
if (!curl_errorstr[0])
strlcpy(curl_errorstr,
curl_easy_strerror(results->curl_result),
sizeof(curl_errorstr));
#endif
return HTTP_ERROR;
}
}

/* http_request() targets */
#define HTTP_REQUEST_STRBUF 0
#define HTTP_REQUEST_FILE 1
Expand Down Expand Up @@ -792,28 +821,7 @@ static int http_request(const char *url, void *result, int target, int options)

if (start_active_slot(slot)) {
run_active_slot(slot);
if (results.curl_result == CURLE_OK)
ret = HTTP_OK;
else if (missing_target(&results))
ret = HTTP_MISSING_TARGET;
else if (results.http_code == 401) {
if (http_auth.username && http_auth.password) {
credential_reject(&http_auth);
ret = HTTP_NOAUTH;
} else {
credential_fill(&http_auth);
init_curl_http_auth(slot->curl);
ret = HTTP_REAUTH;
}
} else {
#if LIBCURL_VERSION_NUM >= 0x070c00
if (!curl_errorstr[0])
strlcpy(curl_errorstr,
curl_easy_strerror(results.curl_result),
sizeof(curl_errorstr));
#endif
ret = HTTP_ERROR;
}
ret = handle_curl_result(slot);
} else {
error("Unable to start HTTP request for %s", url);
ret = HTTP_START_FAILED;
Expand All @@ -822,9 +830,6 @@ static int http_request(const char *url, void *result, int target, int options)
curl_slist_free_all(headers);
strbuf_release(&buf);

if (ret == HTTP_OK)
credential_approve(&http_auth);

return ret;
}

Expand Down
1 change: 1 addition & 0 deletions http.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern int start_active_slot(struct active_request_slot *slot);
extern void run_active_slot(struct active_request_slot *slot);
extern void finish_active_slot(struct active_request_slot *slot);
extern void finish_all_active_slots(void);
extern int handle_curl_result(struct active_request_slot *slot);

#ifdef USE_CURL_MULTI
extern void fill_active_slots(void);
Expand Down
23 changes: 15 additions & 8 deletions remote-curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,16 +362,17 @@ static size_t rpc_in(char *ptr, size_t eltsize,

static int run_slot(struct active_request_slot *slot)
{
int err = 0;
int err;
struct slot_results results;

slot->results = &results;
slot->curl_result = curl_easy_perform(slot->curl);
finish_active_slot(slot);

if (results.curl_result != CURLE_OK) {
err |= error("RPC failed; result=%d, HTTP code = %ld",
results.curl_result, results.http_code);
err = handle_curl_result(slot);
if (err != HTTP_OK && err != HTTP_REAUTH) {
error("RPC failed; result=%d, HTTP code = %ld",
results.curl_result, results.http_code);
}

return err;
Expand Down Expand Up @@ -436,9 +437,11 @@ static int post_rpc(struct rpc_state *rpc)
}

if (large_request) {
err = probe_rpc(rpc);
if (err)
return err;
do {
err = probe_rpc(rpc);
} while (err == HTTP_REAUTH);
if (err != HTTP_OK)
return -1;
}

slot = get_active_slot();
Expand Down Expand Up @@ -525,7 +528,11 @@ static int post_rpc(struct rpc_state *rpc)
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);

err = run_slot(slot);
do {
err = run_slot(slot);
} while (err == HTTP_REAUTH && !large_request && !use_gzip);
if (err != HTTP_OK)
err = -1;

curl_slist_free_all(headers);
free(gzip_body);
Expand Down
16 changes: 14 additions & 2 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -1134,15 +1134,27 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
const char *this = arg;
int symmetric = *next == '.';
unsigned int flags_exclude = flags ^ UNINTERESTING;
static const char head_by_default[] = "HEAD";
unsigned int a_flags;

*dotdot = 0;
next += symmetric;

if (!*next)
next = "HEAD";
next = head_by_default;
if (dotdot == arg)
this = "HEAD";
this = head_by_default;
if (this == head_by_default && next == head_by_default &&
!symmetric) {
/*
* Just ".."? That is not a range but the
* pathspec for the parent directory.
*/
if (!cant_be_filename) {
*dotdot = '.';
return -1;
}
}
if (!get_sha1_committish(this, from_sha1) &&
!get_sha1_committish(next, sha1)) {
struct commit *a, *b;
Expand Down
Loading

0 comments on commit 3503e9a

Please sign in to comment.