Skip to content

Commit fcd91f8

Browse files
committed
Merge branch 'maint'
* maint: backmerge a few more fixes to 1.7.1.X series rev-parse: fix --parse-opt --keep-dashdash --stop-at-non-option fix git branch -m in presence of cross devices Conflicts: RelNotes builtin/rev-parse.c
2 parents 0cc4da3 + c30e742 commit fcd91f8

File tree

4 files changed

+54
-8
lines changed

4 files changed

+54
-8
lines changed

Documentation/RelNotes-1.7.1.2.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Git v1.7.1.2 Release Notes
2+
==========================
3+
4+
Fixes since v1.7.1.1
5+
--------------------
6+
7+
* "git commit" did not honor GIT_REFLOG_ACTION environment variable, resulting
8+
reflog messages for cherry-pick and revert actions to be recorded as "commit".
9+
10+
* "git clone/fetch/pull" issued an incorrect error message when a ref and
11+
a symref that points to the ref were updated at the same time. This
12+
obviously would update them to the same value, and should not result in
13+
an error condition.
14+
15+
* "git diff" inside a tree with many pathnames that have certain
16+
characters has become very slow in 1.7.0 by mistake.
17+
18+
* "git rev-parse --parseopt --stop-at-non-option" did not stop at non option
19+
when --keep-dashdash was in effect.

builtin/rev-parse.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -407,8 +407,8 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
407407
ALLOC_GROW(opts, onb + 1, osz);
408408
memset(opts + onb, 0, sizeof(opts[onb]));
409409
argc = parse_options(argc, argv, prefix, opts, usage,
410-
keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0 |
411-
stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0 |
410+
(keep_dashdash ? PARSE_OPT_KEEP_DASHDASH : 0) |
411+
(stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) |
412412
PARSE_OPT_SHELL_EVAL);
413413

414414
strbuf_addf(&parsed, " --");

refs.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,6 +1090,15 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
10901090
return ret;
10911091
}
10921092

1093+
/*
1094+
* People using contrib's git-new-workdir have .git/logs/refs ->
1095+
* /some/other/path/.git/logs/refs, and that may live on another device.
1096+
*
1097+
* IOW, to avoid cross device rename errors, the temporary renamed log must
1098+
* live into logs/refs.
1099+
*/
1100+
#define TMP_RENAMED_LOG "logs/refs/.tmp-renamed-log"
1101+
10931102
int rename_ref(const char *oldref, const char *newref, const char *logmsg)
10941103
{
10951104
static const char renamed_ref[] = "RENAMED-REF";
@@ -1123,8 +1132,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
11231132
if (write_ref_sha1(lock, orig_sha1, logmsg))
11241133
return error("unable to save current sha1 in %s", renamed_ref);
11251134

1126-
if (log && rename(git_path("logs/%s", oldref), git_path("tmp-renamed-log")))
1127-
return error("unable to move logfile logs/%s to tmp-renamed-log: %s",
1135+
if (log && rename(git_path("logs/%s", oldref), git_path(TMP_RENAMED_LOG)))
1136+
return error("unable to move logfile logs/%s to "TMP_RENAMED_LOG": %s",
11281137
oldref, strerror(errno));
11291138

11301139
if (delete_ref(oldref, orig_sha1, REF_NODEREF)) {
@@ -1150,7 +1159,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
11501159
}
11511160

11521161
retry:
1153-
if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
1162+
if (log && rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newref))) {
11541163
if (errno==EISDIR || errno==ENOTDIR) {
11551164
/*
11561165
* rename(a, b) when b is an existing
@@ -1163,7 +1172,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
11631172
}
11641173
goto retry;
11651174
} else {
1166-
error("unable to move logfile tmp-renamed-log to logs/%s: %s",
1175+
error("unable to move logfile "TMP_RENAMED_LOG" to logs/%s: %s",
11671176
newref, strerror(errno));
11681177
goto rollback;
11691178
}
@@ -1203,8 +1212,8 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
12031212
error("unable to restore logfile %s from %s: %s",
12041213
oldref, newref, strerror(errno));
12051214
if (!logmoved && log &&
1206-
rename(git_path("tmp-renamed-log"), git_path("logs/%s", oldref)))
1207-
error("unable to restore logfile %s from tmp-renamed-log: %s",
1215+
rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", oldref)))
1216+
error("unable to restore logfile %s from "TMP_RENAMED_LOG": %s",
12081217
oldref, strerror(errno));
12091218

12101219
return 1;

t/t1502-rev-parse-parseopt.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,22 @@ test_expect_success 'test --parseopt --keep-dashdash' '
8181
test_cmp expect output
8282
'
8383

84+
cat >expect <<EOF
85+
set -- --foo -- '--' 'arg' '--spam=ham'
86+
EOF
87+
88+
test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option with --' '
89+
git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo -- arg --spam=ham <optionspec >output &&
90+
test_cmp expect output
91+
'
92+
93+
cat > expect <<EOF
94+
set -- --foo -- 'arg' '--spam=ham'
95+
EOF
96+
97+
test_expect_success 'test --parseopt --keep-dashdash --stop-at-non-option without --' '
98+
git rev-parse --parseopt --keep-dashdash --stop-at-non-option -- --foo arg --spam=ham <optionspec >output &&
99+
test_cmp expect output
100+
'
101+
84102
test_done

0 commit comments

Comments
 (0)