Skip to content

Commit 40fdcc5

Browse files
committed
Merge branch 'maint'
* maint: http: treat config options sslCAPath and sslCAInfo as paths Documentation/diff: give --word-diff-regex=. example filter-branch: deal with object name vs. pathname ambiguity in tree-filter check-ignore: correct documentation about output git-p4: clean up after p4 submit failure git-p4: work with a detached head git-p4: add option to system() to return subshell status git-p4: add failing test for submit from detached head remote-http(s): support SOCKS proxies t5813: avoid creating urls that break on cygwin Escape Git's exec path in contrib/rerere-train.sh script allow hooks to ignore their standard input stream rebase-i-exec: Allow space in SHELL_PATH Documentation: make environment variable formatting more consistent
2 parents 1bc8fea + 908a6e4 commit 40fdcc5

15 files changed

+140
-82
lines changed

Documentation/diff-options.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,9 @@ expression to make sure that it matches all non-whitespace characters.
267267
A match that contains a newline is silently truncated(!) at the
268268
newline.
269269
+
270+
For example, `--word-diff-regex=.` will treat each character as a word
271+
and, correspondingly, show differences character by character.
272+
+
270273
The regex can also be set via a diff driver or configuration option, see
271274
linkgit:gitattributes[1] or linkgit:git-config[1]. Giving it explicitly
272275
overrides any diff driver or configuration setting. Diff drivers

Documentation/git-check-ignore.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,9 @@ DESCRIPTION
1616
-----------
1717

1818
For each pathname given via the command-line or from a file via
19-
`--stdin`, show the pattern from .gitignore (or other input files to
20-
the exclude mechanism) that decides if the pathname is excluded or
21-
included. Later patterns within a file take precedence over earlier
22-
ones.
19+
`--stdin`, check whether the file is excluded by .gitignore (or other
20+
input files to the exclude mechanism) and output the path if it is
21+
excluded.
2322

2423
By default, tracked files are not shown at all since they are not
2524
subject to exclude rules; but see `--no-index'.
@@ -32,7 +31,8 @@ OPTIONS
3231

3332
-v, --verbose::
3433
Also output details about the matching pattern (if any)
35-
for each given pathname.
34+
for each given pathname. For precedence rules within and
35+
between exclude sources, see linkgit:gitignore[5].
3636

3737
--stdin::
3838
Read pathnames from the standard input, one per line,

Documentation/git.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ of clones and fetches.
10561056
cloning of shallow repositories.
10571057
See 'GIT_TRACE' for available trace output options.
10581058

1059-
GIT_LITERAL_PATHSPECS::
1059+
'GIT_LITERAL_PATHSPECS'::
10601060
Setting this variable to `1` will cause Git to treat all
10611061
pathspecs literally, rather than as glob patterns. For example,
10621062
running `GIT_LITERAL_PATHSPECS=1 git log -- '*.c'` will search
@@ -1065,15 +1065,15 @@ GIT_LITERAL_PATHSPECS::
10651065
literal paths to Git (e.g., paths previously given to you by
10661066
`git ls-tree`, `--raw` diff output, etc).
10671067

1068-
GIT_GLOB_PATHSPECS::
1068+
'GIT_GLOB_PATHSPECS'::
10691069
Setting this variable to `1` will cause Git to treat all
10701070
pathspecs as glob patterns (aka "glob" magic).
10711071

1072-
GIT_NOGLOB_PATHSPECS::
1072+
'GIT_NOGLOB_PATHSPECS'::
10731073
Setting this variable to `1` will cause Git to treat all
10741074
pathspecs as literal (aka "literal" magic).
10751075

1076-
GIT_ICASE_PATHSPECS::
1076+
'GIT_ICASE_PATHSPECS'::
10771077
Setting this variable to `1` will cause Git to treat all
10781078
pathspecs as case-insensitive.
10791079

@@ -1087,7 +1087,7 @@ GIT_ICASE_PATHSPECS::
10871087
variable when it is invoked as the top level command by the
10881088
end user, to be recorded in the body of the reflog.
10891089

1090-
`GIT_REF_PARANOIA`::
1090+
'GIT_REF_PARANOIA'::
10911091
If set to `1`, include broken or badly named refs when iterating
10921092
over lists of refs. In a normal, non-corrupted repository, this
10931093
does nothing. However, enabling it may help git to detect and
@@ -1098,7 +1098,7 @@ GIT_ICASE_PATHSPECS::
10981098
an operation has touched every ref (e.g., because you are
10991099
cloning a repository to make a backup).
11001100

1101-
`GIT_ALLOW_PROTOCOL`::
1101+
'GIT_ALLOW_PROTOCOL'::
11021102
If set, provide a colon-separated list of protocols which are
11031103
allowed to be used with fetch/push/clone. This is useful to
11041104
restrict recursive submodule initialization from an untrusted

builtin/commit.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "sequencer.h"
3333
#include "notes-utils.h"
3434
#include "mailmap.h"
35+
#include "sigchain.h"
3536

3637
static const char * const builtin_commit_usage[] = {
3738
N_("git commit [<options>] [--] <pathspec>..."),
@@ -1537,8 +1538,10 @@ static int run_rewrite_hook(const unsigned char *oldsha1,
15371538
return code;
15381539
n = snprintf(buf, sizeof(buf), "%s %s\n",
15391540
sha1_to_hex(oldsha1), sha1_to_hex(newsha1));
1541+
sigchain_push(SIGPIPE, SIG_IGN);
15401542
write_in_full(proc.in, buf, n);
15411543
close(proc.in);
1544+
sigchain_pop(SIGPIPE);
15421545
return finish_command(&proc);
15431546
}
15441547

contrib/rerere-train.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ USAGE="$me rev-list-args"
77

88
SUBDIRECTORY_OK=Yes
99
OPTIONS_SPEC=
10-
. $(git --exec-path)/git-sh-setup
10+
. "$(git --exec-path)/git-sh-setup"
1111
require_work_tree
1212
cd_to_toplevel
1313

git-filter-branch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ while read commit parents; do
349349
die "tree filter failed: $filter_tree"
350350

351351
(
352-
git diff-index -r --name-only --ignore-submodules $commit &&
352+
git diff-index -r --name-only --ignore-submodules $commit -- &&
353353
git ls-files --others
354354
) > "$tempdir"/tree-state || exit
355355
git update-index --add --replace --remove --stdin \

git-p4.py

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,16 @@ def p4_has_move_command():
203203
# assume it failed because @... was invalid changelist
204204
return True
205205

206-
def system(cmd):
206+
def system(cmd, ignore_error=False):
207207
expand = isinstance(cmd,basestring)
208208
if verbose:
209209
sys.stderr.write("executing %s\n" % str(cmd))
210210
retcode = subprocess.call(cmd, shell=expand)
211-
if retcode:
211+
if retcode and not ignore_error:
212212
raise CalledProcessError(retcode, cmd)
213213

214+
return retcode
215+
214216
def p4_system(cmd):
215217
"""Specifically invoke p4 as the system command. """
216218
real_cmd = p4_build_cmd(cmd)
@@ -553,7 +555,12 @@ def p4Where(depotPath):
553555
return clientPath
554556

555557
def currentGitBranch():
556-
return read_pipe("git name-rev HEAD").split(" ")[1].strip()
558+
retcode = system(["git", "symbolic-ref", "-q", "HEAD"], ignore_error=True)
559+
if retcode != 0:
560+
# on a detached head
561+
return None
562+
else:
563+
return read_pipe(["git", "name-rev", "HEAD"]).split(" ")[1].strip()
557564

558565
def isValidGitDir(path):
559566
if (os.path.exists(path + "/HEAD")
@@ -1741,44 +1748,47 @@ def applyCommit(self, id):
17411748
#
17421749
# Let the user edit the change description, then submit it.
17431750
#
1744-
if self.edit_template(fileName):
1745-
# read the edited message and submit
1746-
ret = True
1747-
tmpFile = open(fileName, "rb")
1748-
message = tmpFile.read()
1749-
tmpFile.close()
1750-
if self.isWindows:
1751-
message = message.replace("\r\n", "\n")
1752-
submitTemplate = message[:message.index(separatorLine)]
1753-
p4_write_pipe(['submit', '-i'], submitTemplate)
1754-
1755-
if self.preserveUser:
1756-
if p4User:
1757-
# Get last changelist number. Cannot easily get it from
1758-
# the submit command output as the output is
1759-
# unmarshalled.
1760-
changelist = self.lastP4Changelist()
1761-
self.modifyChangelistUser(changelist, p4User)
1762-
1763-
# The rename/copy happened by applying a patch that created a
1764-
# new file. This leaves it writable, which confuses p4.
1765-
for f in pureRenameCopy:
1766-
p4_sync(f, "-f")
1751+
submitted = False
17671752

1768-
else:
1753+
try:
1754+
if self.edit_template(fileName):
1755+
# read the edited message and submit
1756+
tmpFile = open(fileName, "rb")
1757+
message = tmpFile.read()
1758+
tmpFile.close()
1759+
if self.isWindows:
1760+
message = message.replace("\r\n", "\n")
1761+
submitTemplate = message[:message.index(separatorLine)]
1762+
p4_write_pipe(['submit', '-i'], submitTemplate)
1763+
1764+
if self.preserveUser:
1765+
if p4User:
1766+
# Get last changelist number. Cannot easily get it from
1767+
# the submit command output as the output is
1768+
# unmarshalled.
1769+
changelist = self.lastP4Changelist()
1770+
self.modifyChangelistUser(changelist, p4User)
1771+
1772+
# The rename/copy happened by applying a patch that created a
1773+
# new file. This leaves it writable, which confuses p4.
1774+
for f in pureRenameCopy:
1775+
p4_sync(f, "-f")
1776+
submitted = True
1777+
1778+
finally:
17691779
# skip this patch
1770-
ret = False
1771-
print "Submission cancelled, undoing p4 changes."
1772-
for f in editedFiles:
1773-
p4_revert(f)
1774-
for f in filesToAdd:
1775-
p4_revert(f)
1776-
os.remove(f)
1777-
for f in filesToDelete:
1778-
p4_revert(f)
1780+
if not submitted:
1781+
print "Submission cancelled, undoing p4 changes."
1782+
for f in editedFiles:
1783+
p4_revert(f)
1784+
for f in filesToAdd:
1785+
p4_revert(f)
1786+
os.remove(f)
1787+
for f in filesToDelete:
1788+
p4_revert(f)
17791789

17801790
os.remove(fileName)
1781-
return ret
1791+
return submitted
17821792

17831793
# Export git tags as p4 labels. Create a p4 label and then tag
17841794
# with that.
@@ -1854,18 +1864,17 @@ def exportGitTags(self, gitTags):
18541864
def run(self, args):
18551865
if len(args) == 0:
18561866
self.master = currentGitBranch()
1857-
if len(self.master) == 0 or not gitBranchExists("refs/heads/%s" % self.master):
1858-
die("Detecting current git branch failed!")
18591867
elif len(args) == 1:
18601868
self.master = args[0]
18611869
if not branchExists(self.master):
18621870
die("Branch %s does not exist" % self.master)
18631871
else:
18641872
return False
18651873

1866-
allowSubmit = gitConfig("git-p4.allowSubmit")
1867-
if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
1868-
die("%s is not in git-p4.allowSubmit" % self.master)
1874+
if self.master:
1875+
allowSubmit = gitConfig("git-p4.allowSubmit")
1876+
if len(allowSubmit) > 0 and not self.master in allowSubmit.split(","):
1877+
die("%s is not in git-p4.allowSubmit" % self.master)
18691878

18701879
[upstream, settings] = findUpstreamBranchPoint()
18711880
self.depotPath = settings['depot-paths'][0]
@@ -1933,7 +1942,12 @@ def run(self, args):
19331942
self.check()
19341943

19351944
commits = []
1936-
for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (self.origin, self.master)]):
1945+
if self.master:
1946+
commitish = self.master
1947+
else:
1948+
commitish = 'HEAD'
1949+
1950+
for line in read_pipe_lines(["git", "rev-list", "--no-merges", "%s..%s" % (self.origin, commitish)]):
19371951
commits.append(line.strip())
19381952
commits.reverse()
19391953

git-rebase--interactive.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ do_next () {
610610
read -r command rest < "$todo"
611611
mark_action_done
612612
printf 'Executing: %s\n' "$rest"
613-
${SHELL:-@SHELL_PATH@} -c "$rest" # Actual execution
613+
"${SHELL:-@SHELL_PATH@}" -c "$rest" # Actual execution
614614
status=$?
615615
# Run in subshell because require_clean_work_tree can die.
616616
dirty=f

http.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,10 @@ static int http_options(const char *var, const char *value, void *cb)
214214
#endif
215215
#if LIBCURL_VERSION_NUM >= 0x070908
216216
if (!strcmp("http.sslcapath", var))
217-
return git_config_string(&ssl_capath, var, value);
217+
return git_config_pathname(&ssl_capath, var, value);
218218
#endif
219219
if (!strcmp("http.sslcainfo", var))
220-
return git_config_string(&ssl_cainfo, var, value);
220+
return git_config_pathname(&ssl_cainfo, var, value);
221221
if (!strcmp("http.sslcertpasswordprotected", var)) {
222222
ssl_cert_password_required = git_config_bool(var, value);
223223
return 0;
@@ -464,6 +464,17 @@ static CURL *get_curl_handle(void)
464464

465465
if (curl_http_proxy) {
466466
curl_easy_setopt(result, CURLOPT_PROXY, curl_http_proxy);
467+
#if LIBCURL_VERSION_NUM >= 0x071800
468+
if (starts_with(curl_http_proxy, "socks5"))
469+
curl_easy_setopt(result,
470+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
471+
else if (starts_with(curl_http_proxy, "socks4a"))
472+
curl_easy_setopt(result,
473+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4A);
474+
else if (starts_with(curl_http_proxy, "socks"))
475+
curl_easy_setopt(result,
476+
CURLOPT_PROXYTYPE, CURLPROXY_SOCKS4);
477+
#endif
467478
}
468479
#if LIBCURL_VERSION_NUM >= 0x070a07
469480
curl_easy_setopt(result, CURLOPT_PROXYAUTH, CURLAUTH_ANY);

t/t5571-pre-push-hook.sh

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,20 @@ test_expect_success 'push to URL' '
109109
diff expected actual
110110
'
111111

112-
# Test that filling pipe buffers doesn't cause failure
113-
# Too slow to leave enabled for general use
114-
if false
115-
then
116-
printf 'parent1\nrepo1\n' >expected
117-
nr=1000
118-
while test $nr -lt 2000
119-
do
120-
nr=$(( $nr + 1 ))
121-
git branch b/$nr $COMMIT3
122-
echo "refs/heads/b/$nr $COMMIT3 refs/heads/b/$nr $_z40" >>expected
123-
done
124-
125-
test_expect_success 'push many refs' '
126-
git push parent1 "refs/heads/b/*:refs/heads/b/*" &&
127-
diff expected actual
128-
'
129-
fi
112+
test_expect_success 'set up many-ref tests' '
113+
{
114+
nr=1000
115+
while test $nr -lt 2000
116+
do
117+
nr=$(( $nr + 1 ))
118+
echo "create refs/heads/b/$nr $COMMIT3"
119+
done
120+
} | git update-ref --stdin
121+
'
122+
123+
test_expect_success 'sigpipe does not cause pre-push hook failure' '
124+
echo "exit 0" | write_script "$HOOK" &&
125+
git push parent1 "refs/heads/b/*:refs/heads/b/*"
126+
'
130127

131128
test_done

0 commit comments

Comments
 (0)