Skip to content

Commit 3503e9a

Browse files
committed
Merge branch 'maint-1.7.11' into maint
2 parents cbd6b08 + 1403db4 commit 3503e9a

19 files changed

+321
-162
lines changed

Documentation/git-checkout.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ entries; instead, unmerged entries are ignored.
8484
When checking out paths from the index, check out stage #2
8585
('ours') or #3 ('theirs') for unmerged paths.
8686

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

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

127-
--orphan::
127+
--orphan <new_branch>::
128128
Create a new 'orphan' branch, named <new_branch>, started from
129129
<start_point> and switch to it. The first commit made on this
130130
new branch will have no parents and it will be the root of a new

Documentation/revisions.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@ of 'r1' and 'r2' and is defined as
213213
It is the set of commits that are reachable from either one of
214214
'r1' or 'r2' but not from both.
215215

216+
In these two shorthands, you can omit one end and let it default to HEAD.
217+
For example, 'origin..' is a shorthand for 'origin..HEAD' and asks "What
218+
did I do since I forked from the origin branch?" Similarly, '..origin'
219+
is a shorthand for 'HEAD..origin' and asks "What did the origin do since
220+
I forked from them?" Note that '..' would mean 'HEAD..HEAD' which is an
221+
empty range that is both reachable and unreachable from HEAD.
222+
216223
Two other shorthands for naming a set that is formed by a commit
217224
and its parent commits exist. The 'r1{caret}@' notation means all
218225
parents of 'r1'. 'r1{caret}!' includes commit 'r1' but excludes

builtin/apply.c

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,15 +1095,23 @@ static int gitdiff_unrecognized(const char *line, struct patch *patch)
10951095
return -1;
10961096
}
10971097

1098-
static const char *stop_at_slash(const char *line, int llen)
1098+
/*
1099+
* Skip p_value leading components from "line"; as we do not accept
1100+
* absolute paths, return NULL in that case.
1101+
*/
1102+
static const char *skip_tree_prefix(const char *line, int llen)
10991103
{
1100-
int nslash = p_value;
1104+
int nslash;
11011105
int i;
11021106

1107+
if (!p_value)
1108+
return (llen && line[0] == '/') ? NULL : line;
1109+
1110+
nslash = p_value;
11031111
for (i = 0; i < llen; i++) {
11041112
int ch = line[i];
11051113
if (ch == '/' && --nslash <= 0)
1106-
return &line[i];
1114+
return (i == 0) ? NULL : &line[i + 1];
11071115
}
11081116
return NULL;
11091117
}
@@ -1133,12 +1141,11 @@ static char *git_header_name(const char *line, int llen)
11331141
if (unquote_c_style(&first, line, &second))
11341142
goto free_and_fail1;
11351143

1136-
/* advance to the first slash */
1137-
cp = stop_at_slash(first.buf, first.len);
1138-
/* we do not accept absolute paths */
1139-
if (!cp || cp == first.buf)
1144+
/* strip the a/b prefix including trailing slash */
1145+
cp = skip_tree_prefix(first.buf, first.len);
1146+
if (!cp)
11401147
goto free_and_fail1;
1141-
strbuf_remove(&first, 0, cp + 1 - first.buf);
1148+
strbuf_remove(&first, 0, cp - first.buf);
11421149

11431150
/*
11441151
* second points at one past closing dq of name.
@@ -1152,22 +1159,21 @@ static char *git_header_name(const char *line, int llen)
11521159
if (*second == '"') {
11531160
if (unquote_c_style(&sp, second, NULL))
11541161
goto free_and_fail1;
1155-
cp = stop_at_slash(sp.buf, sp.len);
1156-
if (!cp || cp == sp.buf)
1162+
cp = skip_tree_prefix(sp.buf, sp.len);
1163+
if (!cp)
11571164
goto free_and_fail1;
11581165
/* They must match, otherwise ignore */
1159-
if (strcmp(cp + 1, first.buf))
1166+
if (strcmp(cp, first.buf))
11601167
goto free_and_fail1;
11611168
strbuf_release(&sp);
11621169
return strbuf_detach(&first, NULL);
11631170
}
11641171

11651172
/* unquoted second */
1166-
cp = stop_at_slash(second, line + llen - second);
1167-
if (!cp || cp == second)
1173+
cp = skip_tree_prefix(second, line + llen - second);
1174+
if (!cp)
11681175
goto free_and_fail1;
1169-
cp++;
1170-
if (line + llen - cp != first.len + 1 ||
1176+
if (line + llen - cp != first.len ||
11711177
memcmp(first.buf, cp, first.len))
11721178
goto free_and_fail1;
11731179
return strbuf_detach(&first, NULL);
@@ -1179,10 +1185,9 @@ static char *git_header_name(const char *line, int llen)
11791185
}
11801186

11811187
/* unquoted first name */
1182-
name = stop_at_slash(line, llen);
1183-
if (!name || name == line)
1188+
name = skip_tree_prefix(line, llen);
1189+
if (!name)
11841190
return NULL;
1185-
name++;
11861191

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

1199-
np = stop_at_slash(sp.buf, sp.len);
1200-
if (!np || np == sp.buf)
1204+
np = skip_tree_prefix(sp.buf, sp.len);
1205+
if (!np)
12011206
goto free_and_fail2;
1202-
np++;
12031207

12041208
len = sp.buf + sp.len - np;
12051209
if (len < second - name &&
@@ -1231,13 +1235,27 @@ static char *git_header_name(const char *line, int llen)
12311235
case '\n':
12321236
return NULL;
12331237
case '\t': case ' ':
1234-
second = stop_at_slash(name + len, line_len - len);
1238+
/*
1239+
* Is this the separator between the preimage
1240+
* and the postimage pathname? Again, we are
1241+
* only interested in the case where there is
1242+
* no rename, as this is only to set def_name
1243+
* and a rename patch has the names elsewhere
1244+
* in an unambiguous form.
1245+
*/
1246+
if (!name[len + 1])
1247+
return NULL; /* no postimage name */
1248+
second = skip_tree_prefix(name + len + 1,
1249+
line_len - (len + 1));
12351250
if (!second)
12361251
return NULL;
1237-
second++;
1238-
if (second[len] == '\n' && !strncmp(name, second, len)) {
1252+
/*
1253+
* Does len bytes starting at "name" and "second"
1254+
* (that are separated by one HT or SP we just
1255+
* found) exactly match?
1256+
*/
1257+
if (second[len] == '\n' && !strncmp(name, second, len))
12391258
return xmemdupz(name, len);
1240-
}
12411259
}
12421260
}
12431261
}

builtin/for-each-ref.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ static int opt_parse_sort(const struct option *opt, const char *arg, int unset)
962962
if (!arg) /* should --no-sort void the list ? */
963963
return -1;
964964

965-
*sort_tail = s = xcalloc(1, sizeof(*s));
965+
s = xcalloc(1, sizeof(*s));
966+
s->next = *sort_tail;
967+
*sort_tail = s;
966968

967969
if (*arg == '-') {
968970
s->reverse = 1;

builtin/rev-parse.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ static int try_difference(const char *arg)
230230
const char *next;
231231
const char *this;
232232
int symmetric;
233+
static const char head_by_default[] = "HEAD";
233234

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

243244
if (!*next)
244-
next = "HEAD";
245+
next = head_by_default;
245246
if (dotdot == arg)
246-
this = "HEAD";
247+
this = head_by_default;
248+
249+
if (this == head_by_default && next == head_by_default &&
250+
!symmetric) {
251+
/*
252+
* Just ".."? That is not a range but the
253+
* pathspec for the parent directory.
254+
*/
255+
*dotdot = '.';
256+
return 0;
257+
}
258+
247259
if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
248260
show_rev(NORMAL, end, next);
249261
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);

http.c

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,35 @@ char *get_remote_object_url(const char *url, const char *hex,
745745
return strbuf_detach(&buf, NULL);
746746
}
747747

748+
int handle_curl_result(struct active_request_slot *slot)
749+
{
750+
struct slot_results *results = slot->results;
751+
752+
if (results->curl_result == CURLE_OK) {
753+
credential_approve(&http_auth);
754+
return HTTP_OK;
755+
} else if (missing_target(results))
756+
return HTTP_MISSING_TARGET;
757+
else if (results->http_code == 401) {
758+
if (http_auth.username && http_auth.password) {
759+
credential_reject(&http_auth);
760+
return HTTP_NOAUTH;
761+
} else {
762+
credential_fill(&http_auth);
763+
init_curl_http_auth(slot->curl);
764+
return HTTP_REAUTH;
765+
}
766+
} else {
767+
#if LIBCURL_VERSION_NUM >= 0x070c00
768+
if (!curl_errorstr[0])
769+
strlcpy(curl_errorstr,
770+
curl_easy_strerror(results->curl_result),
771+
sizeof(curl_errorstr));
772+
#endif
773+
return HTTP_ERROR;
774+
}
775+
}
776+
748777
/* http_request() targets */
749778
#define HTTP_REQUEST_STRBUF 0
750779
#define HTTP_REQUEST_FILE 1
@@ -792,28 +821,7 @@ static int http_request(const char *url, void *result, int target, int options)
792821

793822
if (start_active_slot(slot)) {
794823
run_active_slot(slot);
795-
if (results.curl_result == CURLE_OK)
796-
ret = HTTP_OK;
797-
else if (missing_target(&results))
798-
ret = HTTP_MISSING_TARGET;
799-
else if (results.http_code == 401) {
800-
if (http_auth.username && http_auth.password) {
801-
credential_reject(&http_auth);
802-
ret = HTTP_NOAUTH;
803-
} else {
804-
credential_fill(&http_auth);
805-
init_curl_http_auth(slot->curl);
806-
ret = HTTP_REAUTH;
807-
}
808-
} else {
809-
#if LIBCURL_VERSION_NUM >= 0x070c00
810-
if (!curl_errorstr[0])
811-
strlcpy(curl_errorstr,
812-
curl_easy_strerror(results.curl_result),
813-
sizeof(curl_errorstr));
814-
#endif
815-
ret = HTTP_ERROR;
816-
}
824+
ret = handle_curl_result(slot);
817825
} else {
818826
error("Unable to start HTTP request for %s", url);
819827
ret = HTTP_START_FAILED;
@@ -822,9 +830,6 @@ static int http_request(const char *url, void *result, int target, int options)
822830
curl_slist_free_all(headers);
823831
strbuf_release(&buf);
824832

825-
if (ret == HTTP_OK)
826-
credential_approve(&http_auth);
827-
828833
return ret;
829834
}
830835

http.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ extern int start_active_slot(struct active_request_slot *slot);
7878
extern void run_active_slot(struct active_request_slot *slot);
7979
extern void finish_active_slot(struct active_request_slot *slot);
8080
extern void finish_all_active_slots(void);
81+
extern int handle_curl_result(struct active_request_slot *slot);
8182

8283
#ifdef USE_CURL_MULTI
8384
extern void fill_active_slots(void);

remote-curl.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,16 +362,17 @@ static size_t rpc_in(char *ptr, size_t eltsize,
362362

363363
static int run_slot(struct active_request_slot *slot)
364364
{
365-
int err = 0;
365+
int err;
366366
struct slot_results results;
367367

368368
slot->results = &results;
369369
slot->curl_result = curl_easy_perform(slot->curl);
370370
finish_active_slot(slot);
371371

372-
if (results.curl_result != CURLE_OK) {
373-
err |= error("RPC failed; result=%d, HTTP code = %ld",
374-
results.curl_result, results.http_code);
372+
err = handle_curl_result(slot);
373+
if (err != HTTP_OK && err != HTTP_REAUTH) {
374+
error("RPC failed; result=%d, HTTP code = %ld",
375+
results.curl_result, results.http_code);
375376
}
376377

377378
return err;
@@ -436,9 +437,11 @@ static int post_rpc(struct rpc_state *rpc)
436437
}
437438

438439
if (large_request) {
439-
err = probe_rpc(rpc);
440-
if (err)
441-
return err;
440+
do {
441+
err = probe_rpc(rpc);
442+
} while (err == HTTP_REAUTH);
443+
if (err != HTTP_OK)
444+
return -1;
442445
}
443446

444447
slot = get_active_slot();
@@ -525,7 +528,11 @@ static int post_rpc(struct rpc_state *rpc)
525528
curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in);
526529
curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc);
527530

528-
err = run_slot(slot);
531+
do {
532+
err = run_slot(slot);
533+
} while (err == HTTP_REAUTH && !large_request && !use_gzip);
534+
if (err != HTTP_OK)
535+
err = -1;
529536

530537
curl_slist_free_all(headers);
531538
free(gzip_body);

revision.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,15 +1134,27 @@ int handle_revision_arg(const char *arg_, struct rev_info *revs, int flags, unsi
11341134
const char *this = arg;
11351135
int symmetric = *next == '.';
11361136
unsigned int flags_exclude = flags ^ UNINTERESTING;
1137+
static const char head_by_default[] = "HEAD";
11371138
unsigned int a_flags;
11381139

11391140
*dotdot = 0;
11401141
next += symmetric;
11411142

11421143
if (!*next)
1143-
next = "HEAD";
1144+
next = head_by_default;
11441145
if (dotdot == arg)
1145-
this = "HEAD";
1146+
this = head_by_default;
1147+
if (this == head_by_default && next == head_by_default &&
1148+
!symmetric) {
1149+
/*
1150+
* Just ".."? That is not a range but the
1151+
* pathspec for the parent directory.
1152+
*/
1153+
if (!cant_be_filename) {
1154+
*dotdot = '.';
1155+
return -1;
1156+
}
1157+
}
11461158
if (!get_sha1_committish(this, from_sha1) &&
11471159
!get_sha1_committish(next, sha1)) {
11481160
struct commit *a, *b;

0 commit comments

Comments
 (0)