* Re: [PATCH 5/5] unpack-trees: do not capitalize "working"
From: Matthieu Moy @ 2016-09-08 6:36 UTC (permalink / raw)
To: Alex Henrie; +Cc: vascomalmeida, gitster, git
In-Reply-To: <20160908043453.6044-1-alexhenrie24@gmail.com>
Alex Henrie <alexhenrie24@gmail.com> writes:
> In English, only proper nouns are capitalized.
>
> Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
> ---
> unpack-trees.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/unpack-trees.c b/unpack-trees.c
> index 11c37fb..c87a90a 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -123,9 +123,9 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
> msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] =
> _("Cannot update sparse checkout: the following entries are not up-to-date:\n%s");
> msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] =
> - _("The following Working tree files would be overwritten by sparse checkout update:\n%s");
> + _("The following working tree files would be overwritten by sparse checkout update:\n%s");
> msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
> - _("The following Working tree files would be removed by sparse checkout update:\n%s");
> + _("The following working tree files would be removed by sparse checkout update:\n%s");
Probably a leftover from an old sentence starting with Working? In any
case, obviously correct too, thanks.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* Re: [PATCH 3/5] git-rebase--interactive: fix English grammar
From: Matthieu Moy @ 2016-09-08 6:35 UTC (permalink / raw)
To: Alex Henrie; +Cc: gitster, git
In-Reply-To: <20160908043417.5946-1-alexhenrie24@gmail.com>
Alex Henrie <alexhenrie24@gmail.com> writes:
> --- a/git-rebase--interactive.sh
> +++ b/git-rebase--interactive.sh
> @@ -1082,7 +1082,7 @@ If they are meant to go into a new commit, run:
>
> git commit \$gpg_sign_opt_quoted
>
> -In both case, once you're done, continue with:
> +In both cases, once you're done, continue with:
I don't remember writing this, but since I'm Cc-ed I guess I did ;-).
Obviously correct, thanks.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply
* Re: [PATCH 1/3] diff.c: use diff_options directly
From: Jacob Keller @ 2016-09-08 5:33 UTC (permalink / raw)
To: Stefan Beller; +Cc: Junio C Hamano, Git mailing list
In-Reply-To: <20160907233648.5162-2-sbeller@google.com>
On Wed, Sep 7, 2016 at 4:36 PM, Stefan Beller <sbeller@google.com> wrote:
> The value of `ecbdata->opt` is accessible via the short variable `o`
> already, so let's use that instead.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
Seems reasonable.
> ---
> diff.c | 21 ++++++++++-----------
> 1 file changed, 10 insertions(+), 11 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 534c12e..4a6501c 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1217,7 +1217,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> const char *line_prefix = diff_line_prefix(o);
>
> if (ecbdata->header) {
> - fprintf(ecbdata->opt->file, "%s", ecbdata->header->buf);
> + fprintf(o->file, "%s", ecbdata->header->buf);
> strbuf_reset(ecbdata->header);
> ecbdata->header = NULL;
> }
> @@ -1229,9 +1229,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
> name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
>
> - fprintf(ecbdata->opt->file, "%s%s--- %s%s%s\n",
> + fprintf(o->file, "%s%s--- %s%s%s\n",
> line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
> - fprintf(ecbdata->opt->file, "%s%s+++ %s%s%s\n",
> + fprintf(o->file, "%s%s+++ %s%s%s\n",
> line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
> ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
> }
> @@ -1249,15 +1249,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> find_lno(line, ecbdata);
> emit_hunk_header(ecbdata, line, len);
> if (line[len-1] != '\n')
> - putc('\n', ecbdata->opt->file);
> + putc('\n', o->file);
> return;
> }
>
> if (len < 1) {
> - emit_line(ecbdata->opt, reset, reset, line, len);
> + emit_line(o, reset, reset, line, len);
> if (ecbdata->diff_words
> && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
> - fputs("~\n", ecbdata->opt->file);
> + fputs("~\n", o->file);
> return;
> }
>
> @@ -1282,8 +1282,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> }
> diff_words_flush(ecbdata);
> if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
> - emit_line(ecbdata->opt, context, reset, line, len);
> - fputs("~\n", ecbdata->opt->file);
> + emit_line(o, context, reset, line, len);
> + fputs("~\n", o->file);
> } else {
> /*
> * Skip the prefix character, if any. With
> @@ -1294,7 +1294,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> line++;
> len--;
> }
> - emit_line(ecbdata->opt, context, reset, line, len);
> + emit_line(o, context, reset, line, len);
> }
> return;
> }
> @@ -1316,8 +1316,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> default:
> /* incomplete line at the end */
> ecbdata->lno_in_preimage++;
> - emit_line(ecbdata->opt,
> - diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
> + emit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
> reset, line, len);
> break;
> }
> --
> 2.10.0.2.g0676c79.dirty
>
^ permalink raw reply
* Re: [PATCH v1 2/2] read-cache: make sure file handles are not inherited by child processes
From: Lars Schneider @ 2016-09-08 5:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Eric Wong, Git Mailing List, tboegi, Johannes.Schindelin
In-Reply-To: <xmqqtwdrmuvo.fsf@gitster.mtv.corp.google.com>
> On 07 Sep 2016, at 20:23, Junio C Hamano <gitster@pobox.com> wrote:
>
> Eric Wong <e@80x24.org> writes:
>
>> We probably should be using O_NOATIME for all O_RDONLY cases
>> to get the last bit of performance out (especially since
>> non-modern-Linux systems probably still lack relatime).
>
> No, please do not go there.
>
> The user can read from a file in a working tree using "less",
> "grep", etc., and they all update the atime, so should "git grep".
> We do not use atime ourselves on these files but we should let
> outside tools rely on the validity of atime (e.g. "what are the
> files that were looked at yesterday?").
>
> If you grep for noatime in our current codebase, you'd notice that
> we use it only for files in objects/ hierarchy, and that makes very
> good sense. These files are what we create for our _sole_ use and
> no other tools can peek at them and expect to get any useful
> information out of them (we hear from time to time that virus
> scanners leaving open file descriptors on them causing trouble, but
> that is an example of a useless access), and that makes a file in
> objects/ hierarchy a fair game for noatime optimization.
How do we deal with read-cache:ce_compare_data, though?
By your definition above we shouldn't use NOATIME since the read file
is not in objects/. However, the file read is not something the user
explicitly triggers. The read is part of the Git internal "clean"
machinery.
What would you suggest? Should I open the file with or without NOATIME?
Thanks,
Lars
^ permalink raw reply
* [PATCH 5/5] unpack-trees: do not capitalize "working"
From: Alex Henrie @ 2016-09-08 4:34 UTC (permalink / raw)
To: vascomalmeida, Matthieu.Moy, gitster, git; +Cc: Alex Henrie
In English, only proper nouns are capitalized.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
unpack-trees.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/unpack-trees.c b/unpack-trees.c
index 11c37fb..c87a90a 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -123,9 +123,9 @@ void setup_unpack_trees_porcelain(struct unpack_trees_options *opts,
msgs[ERROR_SPARSE_NOT_UPTODATE_FILE] =
_("Cannot update sparse checkout: the following entries are not up-to-date:\n%s");
msgs[ERROR_WOULD_LOSE_ORPHANED_OVERWRITTEN] =
- _("The following Working tree files would be overwritten by sparse checkout update:\n%s");
+ _("The following working tree files would be overwritten by sparse checkout update:\n%s");
msgs[ERROR_WOULD_LOSE_ORPHANED_REMOVED] =
- _("The following Working tree files would be removed by sparse checkout update:\n%s");
+ _("The following working tree files would be removed by sparse checkout update:\n%s");
opts->show_all_errors = 1;
/* rejected paths may not have a static buffer */
--
2.9.3
^ permalink raw reply related
* [PATCH 4/5] git-merge-octopus: do not capitalize "octopus"
From: Alex Henrie @ 2016-09-08 4:34 UTC (permalink / raw)
To: vascomalmeida, gitster, git; +Cc: Alex Henrie
In English, only proper nouns are capitalized.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
git-merge-octopus.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-merge-octopus.sh b/git-merge-octopus.sh
index 308eafd..bcf0d92 100755
--- a/git-merge-octopus.sh
+++ b/git-merge-octopus.sh
@@ -30,7 +30,7 @@ do
esac
done
-# Reject if this is not an Octopus -- resolve should be used instead.
+# Reject if this is not an octopus -- resolve should be used instead.
case "$remotes" in
?*' '?*)
;;
@@ -59,7 +59,7 @@ do
# conflicts. Last round failed and we still had
# a head to merge.
gettextln "Automated merge did not work."
- gettextln "Should not be doing an Octopus."
+ gettextln "Should not be doing an octopus."
exit 2
esac
--
2.9.3
^ permalink raw reply related
* [PATCH 3/5] git-rebase--interactive: fix English grammar
From: Alex Henrie @ 2016-09-08 4:34 UTC (permalink / raw)
To: Matthieu.Moy, gitster, git; +Cc: Alex Henrie
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
git-rebase--interactive.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 7e558b0..6fd6d4e 100644
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -1082,7 +1082,7 @@ If they are meant to go into a new commit, run:
git commit \$gpg_sign_opt_quoted
-In both case, once you're done, continue with:
+In both cases, once you're done, continue with:
git rebase --continue
")"
--
2.9.3
^ permalink raw reply related
* [PATCH 2/5] cat-file: put spaces around pipes in usage string
From: Alex Henrie @ 2016-09-08 4:34 UTC (permalink / raw)
To: karthik.188, gitster, git; +Cc: Alex Henrie
This makes the style a little more consistent with other usage strings,
and will resolve a warning at
https://www.softcatala.org/recursos/quality/git.html
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
builtin/cat-file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 2dfe626..560f6c2 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -440,7 +440,7 @@ static int batch_objects(struct batch_options *opt)
}
static const char * const cat_file_usage[] = {
- N_("git cat-file (-t [--allow-unknown-type]|-s [--allow-unknown-type]|-e|-p|<type>|--textconv) <object>"),
+ N_("git cat-file (-t [--allow-unknown-type] | -s [--allow-unknown-type] | -e | -p | <type> | --textconv) <object>"),
N_("git cat-file (--batch | --batch-check) [--follow-symlinks]"),
NULL
};
--
2.9.3
^ permalink raw reply related
* [PATCH 1/5] am: put spaces around pipe in usage string
From: Alex Henrie @ 2016-09-08 4:33 UTC (permalink / raw)
To: ralf.thielow, pyokagan, gitster, git; +Cc: Alex Henrie
This makes the style a little more consistent with other usage strings,
and will resolve a warning at
https://www.softcatala.org/recursos/quality/git.html
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
---
builtin/am.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin/am.c b/builtin/am.c
index 739b34d..9e2ae5c 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2222,7 +2222,7 @@ int cmd_am(int argc, const char **argv, const char *prefix)
int in_progress;
const char * const usage[] = {
- N_("git am [<options>] [(<mbox>|<Maildir>)...]"),
+ N_("git am [<options>] [(<mbox> | <Maildir>)...]"),
N_("git am [<options>] (--continue | --skip | --abort)"),
NULL
};
--
2.9.3
^ permalink raw reply related
* Re: [PATCH] connect: tighten check for unexpected early hang up (Re: [PATCH v3 2/2] connect: advertized capability is not a ref)
From: Jonathan Nieder @ 2016-09-08 1:50 UTC (permalink / raw)
To: Jonathan Tan; +Cc: git, spearce, sbeller, peff, gitster, Heiko Voigt
In-Reply-To: <20160908014555.GD25016@google.com>
Jonathan Nieder wrote:
> Subject: connect: tighten check for unexpected early hang up
[...]
> @@ -131,7 +131,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
> PACKET_READ_GENTLE_ON_EOF |
> PACKET_READ_CHOMP_NEWLINE);
> if (len < 0)
> - die_initial_contact(got_at_least_one_head);
> + die_initial_contact(first_line);
This should say !first_line.
I'll add tests if the patch seems like a good idea.
Thanks,
Jonathan
^ permalink raw reply
* Re: [PATCH] connect: tighten check for unexpected early hang up (Re: [PATCH v3 2/2] connect: advertized capability is not a ref)
From: Jonathan Nieder @ 2016-09-08 1:46 UTC (permalink / raw)
To: Jonathan Tan; +Cc: git, spearce, sbeller, peff, gitster, Heiko Voigt
In-Reply-To: <20160908014555.GD25016@google.com>
Jonathan Nieder wrote:
> Change-Id: I3cec2c160eb6c6f3efdce7dab38a4c78592f6c7f
Gah --- sorry about that. Please remove this line if applying (or
I'll be happy to resend without it after review).
Jonathan
^ permalink raw reply
* [PATCH] connect: tighten check for unexpected early hang up (Re: [PATCH v3 2/2] connect: advertized capability is not a ref)
From: Jonathan Nieder @ 2016-09-08 1:45 UTC (permalink / raw)
To: Jonathan Tan; +Cc: git, spearce, sbeller, peff, gitster, Heiko Voigt
In-Reply-To: <20160908013431.GC25016@google.com>
(+cc: Heiko)
Jonathan Nieder wrote:
> 'die_initial_contact' uses got_at_least_one_head to determine whether
> it was on the first line but code paths added later that use
> 'continue' don't populate it properly (see b06dcd7d, 40c155ff, and
> 1a7141ff). We could do
>
> int first_line = 1;
>
> for (;; first_line = 0) {
> ...
> }
>
> and use !first_line instead of got_at_least_one_head (removing
> got_at_least_one_head in the process since it has no other purpose).
I got the history wrong. It looks like this was always confused
by the 'continue' cases. Unless I'm missing something subtle ---
thoughts?
Thanks,
Jonathan
-- >8 --
Subject: connect: tighten check for unexpected early hang up
A server hanging up immediately to mark access being denied does not
send any .have refs, shallow lines, or anything else before hanging
up. If the server has sent anything, then the hangup is unexpected.
That is, if the server hangs up after a shallow line but before sending
any refs, then git should tell me so:
fatal: The remote end hung up upon initial contact
instead of suggesting an access control problem:
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Noticed while examining this code. This case isn't likely to come up
in practice but tightening the check makes the code easier to read and
manipulate.
Change-Id: I3cec2c160eb6c6f3efdce7dab38a4c78592f6c7f
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
connect.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/connect.c b/connect.c
index 722dc3f..2c2ebef 100644
--- a/connect.c
+++ b/connect.c
@@ -43,9 +43,9 @@ int check_ref_type(const struct ref *ref, int flags)
return check_ref(ref->name, flags);
}
-static void die_initial_contact(int got_at_least_one_head)
+static void die_initial_contact(int unexpected)
{
- if (got_at_least_one_head)
+ if (unexpected)
die("The remote end hung up upon initial contact");
else
die("Could not read from remote repository.\n\n"
@@ -115,10 +115,10 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
struct sha1_array *shallow_points)
{
struct ref **orig_list = list;
- int got_at_least_one_head = 0;
+ int first_line = 1;
*list = NULL;
- for (;;) {
+ for (;; first_line = 0) {
struct ref *ref;
struct object_id old_oid;
char *name;
@@ -131,7 +131,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
PACKET_READ_GENTLE_ON_EOF |
PACKET_READ_CHOMP_NEWLINE);
if (len < 0)
- die_initial_contact(got_at_least_one_head);
+ die_initial_contact(first_line);
if (!len)
break;
@@ -171,7 +171,6 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
oidcpy(&ref->old_oid, &old_oid);
*list = ref;
list = &ref->next;
- got_at_least_one_head = 1;
}
annotate_refs_with_symref_info(*orig_list);
--
^ permalink raw reply related
* Re: [PATCH v3 2/2] connect: advertized capability is not a ref
From: Jonathan Nieder @ 2016-09-08 1:34 UTC (permalink / raw)
To: Jonathan Tan; +Cc: git, spearce, sbeller, peff, gitster
In-Reply-To: <4b09bb7a5b7f4eb5fc31df3d98ce7ffc042eb367.1473291819.git.jonathantanmy@google.com>
Jonathan Tan wrote:
> Git advertises the same capabilities^{} ref in its ref advertisement for push
> but since it never remembered to do so for fetch, the client forgot to handle
> this case. Handle it.
The comment in the previous review was that this doesn't describe the
history correctly. It can instead say something like
Git advertises the same capabilities^{} ref in its ref advertisement for push
but since it never did so for fetch, the client didn't need to handle this
case. Handle it.
[...]
> @@ -165,8 +166,24 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
> continue;
> }
>
> + if (!strcmp(name, "capabilities^{}")) {
> + if (got_at_least_one_head)
> + warning("protocol error: unexpected dummy ref for "
> + "capabilities declaration, continuing anyway");
Can this die() instead of warning?
I think mentioning capabilities^{} in the error message would make it
easier to debug.
> + if (got_dummy_ref_with_capabilities_declaration)
> + warning("protocol error: multiple dummy refs for "
> + "capabilities declaration, continuing anyway");
Likewise.
> + got_dummy_ref_with_capabilities_declaration = 1;
> + continue;
I think we can make this stricter. The capabilities^{} line is supposed
to be the first advertised ref, before any 'shallow' lines or .have
extra refs.
(Alas, Documentation/technical/pack-protocol.txt doesn't describe
.have refs --- v1.6.1-rc1~203^2~1, push: prepare sender to receive
extended ref information from the receiver, 2008-09-09.)
'die_initial_contact' uses got_at_least_one_head to determine whether
it was on the first line but code paths added later that use
'continue' don't populate it properly (see b06dcd7d, 40c155ff, and
1a7141ff). We could do
int first_line = 1;
for (;; first_line = 0) {
...
}
and use !first_line instead of got_at_least_one_head (removing
got_at_least_one_head in the process since it has no other purpose).
Thanks,
Jonathan
^ permalink raw reply
* Re: "fatal error in commit_refs" from pushing to github
From: Jeff King @ 2016-09-08 1:25 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Git Mailing List
In-Reply-To: <CACsJy8BF_mnSUcEeH=RBMyfh8RrQGJ4dwm_svsC4TciJtECn_w@mail.gmail.com>
On Thu, Sep 08, 2016 at 07:49:12AM +0700, Duy Nguyen wrote:
> I got the message in the subject when pushing to github today. Yes I
> know it's github, not git. But according to stackoveflow [1] it's a
> local problem. Which makes me think, if we know exactly what this is
> (or at least roughly the problem area), maybe we could improve git to
> catch it locally in the first place (and because other git servers may
> not have the same protection as github). Jeff maybe you can reveal
> something about this "fatal error in commit_refs"? I'm sure it's not
> in git code. But I would understand if the answer is "no".
The short answer is that it's nothing to do with Git or the client; it's
GitHub-specific code running on the server that is outside of Git
entirely.
The long answer is that pushes to GitHub don't hit Git directly these
days. They hit a proxy layer that speaks just enough of the Git protocol
to relay to N separate receives spread across N replica servers[1]. Those
receive-packs take in the pack and verify it, but don't actually update
any refs[2]. Then the proxy layer runs its own set of policy hooks, and
speaks a commit-protocol to each of the replicas so that they all agree
on the new ref state. That last step is called "commit_refs" internally.
So this is really an internal failure at the ref-update stage. There
_should_ be a reasonable error message, but I think "fatal error in
commit_refs" is the generic last-ditch fallback. I'll pass this along to
people in charge of that code, as we should be generating a more useful
error message.
-Peff
[1] I glossed over a lot of details there. If you're interested:
http://githubengineering.com/introducing-dgit/
http://githubengineering.com/building-resilience-in-spokes/
[2] Initially the proxy just fed a set of temporary refs to
receive-pack, and it was completely stock. These days we do have
a trivial patch that skips the ref write. I haven't sent it upstream
because it's useless by itself (but it's below for reference).
I'm happy to polish it if somebody actually has a use for it.
---
Documentation/config.txt | 8 ++++++++
builtin/receive-pack.c | 13 +++++++++++--
t/t9944-receive-pack-nowrite.sh | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 2 deletions(-)
create mode 100755 t/t9944-receive-pack-nowrite.sh
diff --git a/Documentation/config.txt b/Documentation/config.txt
index f8e6484..38cc1ac 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2406,6 +2406,14 @@ receive.refUpdateNameLimit::
is a hard limit of 65520 bytes due to git's protocol, so this
value must be smaller than that.
+receive.writeRefs::
+ If set to `false`, `receive-pack` will perform all of the usual
+ ref consistency checks (checking for non-ff, etc), but _not_
+ actually write any ref changes to disk (nor even check that such
+ writes would succeed, as doing so atomically would require
+ taking individual ref locks to be of any value). The default is
+ `true`.
+
remote.pushDefault::
The remote to push to by default. Overrides
`branch.<name>.remote` for all branches, and is overridden by
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 94704e7..4a87365 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -87,6 +87,8 @@ static long nonce_stamp_slop;
static unsigned long nonce_stamp_slop_limit;
static struct ref_transaction *transaction;
+static int write_refs = 1;
+
static enum deny_action parse_deny_action(const char *var, const char *value)
{
if (value) {
@@ -244,6 +246,11 @@ static int receive_pack_config(const char *var, const char *value, void *cb)
return 0;
}
+ if (strcmp(var, "receive.writerefs") == 0) {
+ write_refs = git_config_bool(var, value);
+ return 0;
+ }
+
return git_default_config(var, value, cb);
}
@@ -1060,7 +1067,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
cmd->did_not_exist = 1;
}
}
- if (ref_transaction_delete(transaction,
+ if (write_refs &&
+ ref_transaction_delete(transaction,
namespaced_name,
old_sha1,
flags, "push", &err)) {
@@ -1077,7 +1085,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
update_shallow_ref(cmd, si))
return "shallow error";
- if (ref_transaction_update(transaction,
+ if (write_refs &&
+ ref_transaction_update(transaction,
namespaced_name,
new_sha1, old_sha1,
flags, "push",
diff --git a/t/t9944-receive-pack-nowrite.sh b/t/t9944-receive-pack-nowrite.sh
new file mode 100755
index 0000000..7b27bc1
--- /dev/null
+++ b/t/t9944-receive-pack-nowrite.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='test no-write tweak to receive-pack'
+. ./test-lib.sh
+
+test_expect_success 'create a few commits' '
+ test_commit one &&
+ git update-ref refs/heads/a HEAD &&
+ test_commit two &&
+ git update-ref refs/heads/b HEAD &&
+ test_commit three &&
+ git update-ref refs/heads/c HEAD
+'
+
+# push just two; hold back "c" so we can push a creation later
+test_expect_success 'create destination repo' '
+ git init --bare dst.git &&
+ git for-each-ref refs/heads/a refs/heads/b >expect &&
+ git push dst.git a b &&
+ git -C dst.git for-each-ref >actual &&
+ test_cmp expect actual
+'
+
+# push an update, a deletion, and a creation
+test_expect_success 'push with no-write config set' '
+ git push --receive-pack="git -c \
+ receive.writeRefs=false \
+ receive-pack" \
+ dst.git b:a :b c:c
+'
+
+test_expect_success 'push did not touch real refs' '
+ git -C dst.git for-each-ref >actual &&
+ test_cmp expect actual
+'
+
+test_done
--
2.10.0.rc2.154.gb4a4b8b
^ permalink raw reply related
* [PATCH] Move format-patch base commit and prerequisites before email signature
From: Josh Triplett @ 2016-09-08 1:12 UTC (permalink / raw)
To: git
Any text below the "-- " for the email signature gets treated as part of
the signature, and many mail clients will trim it from the quoted text
for a reply. Move it above the signature, so people can reply to it
more easily.
Add tests for the exact format of the email signature, and add tests to
ensure the email signature appears last.
(Patch by Junio Hamano; tests by Josh Triplett.)
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
---
Does the above seem reasonable, for a patch that incorporates the
proposed patch from Message-Id
xmqqh99rpud4.fsf@gitster.mtv.corp.google.com and adds tests?
Alternatively, feel free to split this patch into two, the first with
you as the author. I can confirm that the code change doesn't break any
existing tests; only the new tests added here check for it. So a
two-patch series wouldn't result in any breakage after the first patch.
builtin/log.c | 4 ++--
t/t4014-format-patch.sh | 22 +++++++++++++++++-----
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 92dc34d..d69d5e6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -1042,7 +1042,6 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
diff_flush(&opts);
fprintf(rev->diffopt.file, "\n");
- print_signature(rev->diffopt.file);
}
static const char *clean_message_id(const char *msg_id)
@@ -1720,6 +1719,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
make_cover_letter(&rev, use_stdout,
origin, nr, list, branch_name, quiet);
print_bases(&bases, rev.diffopt.file);
+ print_signature(rev.diffopt.file);
total++;
start_number--;
}
@@ -1779,13 +1779,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
if (!use_stdout)
rev.shown_one = 0;
if (shown) {
+ print_bases(&bases, rev.diffopt.file);
if (rev.mime_boundary)
fprintf(rev.diffopt.file, "\n--%s%s--\n\n\n",
mime_boundary_leader,
rev.mime_boundary);
else
print_signature(rev.diffopt.file);
- print_bases(&bases, rev.diffopt.file);
}
if (!use_stdout)
fclose(rev.diffopt.file);
diff --git a/t/t4014-format-patch.sh b/t/t4014-format-patch.sh
index b0579dd..a4af275 100755
--- a/t/t4014-format-patch.sh
+++ b/t/t4014-format-patch.sh
@@ -754,9 +754,22 @@ test_expect_success 'format-patch --ignore-if-in-upstream HEAD' '
git format-patch --ignore-if-in-upstream HEAD
'
+git_version="$(git --version | sed "s/.* //")"
+
+signature() {
+ printf "%s\n%s\n\n" "-- " "${1:-$git_version}"
+}
+
+test_expect_success 'format-patch default signature' '
+ git format-patch --stdout -1 | tail -n 3 >output &&
+ signature >expect &&
+ test_cmp expect output
+'
+
test_expect_success 'format-patch --signature' '
- git format-patch --stdout --signature="my sig" -1 >output &&
- grep "my sig" output
+ git format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&
+ signature "my sig" >expect &&
+ test_cmp expect output
'
test_expect_success 'format-patch with format.signature config' '
@@ -1502,12 +1515,11 @@ test_expect_success 'format-patch -o overrides format.outputDirectory' '
test_expect_success 'format-patch --base' '
git checkout side &&
- git format-patch --stdout --base=HEAD~3 -1 >patch &&
- grep "^base-commit:" patch >actual &&
- grep "^prerequisite-patch-id:" patch >>actual &&
+ git format-patch --stdout --base=HEAD~3 -1 | tail -n 6 >actual &&
echo "base-commit: $(git rev-parse HEAD~3)" >expected &&
echo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \$1}")" >>expected &&
echo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \$1}")" >>expected &&
+ signature >> expected &&
test_cmp expected actual
'
base-commit: 6ebdac1bab966b720d776aa43ca188fe378b1f4b
--
git-series 0.8.10
^ permalink raw reply related
* Re: [PATCH 2/3] diff_flush_patch_id: stop returning error result
From: Ramsay Jones @ 2016-09-08 0:51 UTC (permalink / raw)
To: Jeff King, git
Cc: Michael Haggerty, Kevin Willford, Xiaolong Ye,
Johannes Schindelin, Josh Triplett
In-Reply-To: <20160907220409.oowxymhvkof2xsk5@sigill.intra.peff.net>
On 07/09/16 23:04, Jeff King wrote:
> All of our errors come from diff_get_patch_id(), which has
> exactly three error conditions. The first is an internal
> assertion, which should be a die("BUG") in the first place.
>
> The other two are caused by an inability to two diff blobs,
^^^^^^^^^^^^^^^^^
Huh? ... to diff two blobs?
ATB,
Ramsay Jones
^ permalink raw reply
* "fatal error in commit_refs" from pushing to github
From: Duy Nguyen @ 2016-09-08 0:49 UTC (permalink / raw)
To: Git Mailing List, Jeff King
I got the message in the subject when pushing to github today. Yes I
know it's github, not git. But according to stackoveflow [1] it's a
local problem. Which makes me think, if we know exactly what this is
(or at least roughly the problem area), maybe we could improve git to
catch it locally in the first place (and because other git servers may
not have the same protection as github). Jeff maybe you can reveal
something about this "fatal error in commit_refs"? I'm sure it's not
in git code. But I would understand if the answer is "no".
$ git push origin +ZZZ
Counting objects: 95, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (39/39), done.
Writing objects: 100% (95/95), 15.78 KiB | 0 bytes/s, done.
Total 95 (delta 80), reused 69 (delta 56)
remote: Resolving deltas: 100% (80/80), completed with 49 local objects.
remote: fatal error in commit_refs
To github.com:XXX/YYY.git
! [remote rejected] ZZZ -> ZZZ (failure)
error: failed to push some refs to 'git@github.com:XXX/YYY.git'
[1] https://stackoverflow.com/questions/37341960/how-do-i-fix-remote-fatal-error-in-commit-refs-errors-trying-to-push-with-git
--
Duy
^ permalink raw reply
* [PATCH v3 2/2] connect: advertized capability is not a ref
From: Jonathan Tan @ 2016-09-07 23:50 UTC (permalink / raw)
To: git; +Cc: Jonathan Tan, jrnieder, spearce, sbeller, peff, gitster
In-Reply-To: <cover.1473291819.git.jonathantanmy@google.com>
When cloning an empty repository served by standard git, "git clone" produces
the following reassuring message:
$ git clone git://localhost/tmp/empty
Cloning into 'empty'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.
Meanwhile when cloning an empty repository served by JGit, the output is more
haphazard:
$ git clone git://localhost/tmp/empty
Cloning into 'empty'...
Checking connectivity... done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
This is a common command to run immediately after creating a remote repository
as preparation for adding content to populate it and pushing. The warning is
confusing and needlessly worrying.
The cause is that, since v3.1.0.201309270735-rc1~22 (Advertise capabilities
with no refs in upload service., 2013-08-08), JGit's ref advertisement includes
a ref named capabilities^{} to advertise its capabilities on, while git's ref
advertisement is empty in this case. This allows the client to learn about the
server's capabilities and is needed, for example, for fetch-by-sha1 to work
when no refs are advertised.
This also affects "ls-remote". For example, against an empty repository served
by JGit:
$ git ls-remote git://localhost/tmp/empty
0000000000000000000000000000000000000000 capabilities^{}
Git advertises the same capabilities^{} ref in its ref advertisement for push
but since it never remembered to do so for fetch, the client forgot to handle
this case. Handle it.
In this aspect, JGit is compliant with the specification in pack-protocol.txt.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
connect.c | 17 +++++++++++++++++
t/t5512-ls-remote.sh | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/connect.c b/connect.c
index 722dc3f..0bb8103 100644
--- a/connect.c
+++ b/connect.c
@@ -116,6 +116,7 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
{
struct ref **orig_list = list;
int got_at_least_one_head = 0;
+ int got_dummy_ref_with_capabilities_declaration = 0;
*list = NULL;
for (;;) {
@@ -165,8 +166,24 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
continue;
}
+ if (!strcmp(name, "capabilities^{}")) {
+ if (got_at_least_one_head)
+ warning("protocol error: unexpected dummy ref for "
+ "capabilities declaration, continuing anyway");
+ if (got_dummy_ref_with_capabilities_declaration)
+ warning("protocol error: multiple dummy refs for "
+ "capabilities declaration, continuing anyway");
+ got_dummy_ref_with_capabilities_declaration = 1;
+ continue;
+ }
+
if (!check_ref(name, flags))
continue;
+
+ if (got_dummy_ref_with_capabilities_declaration)
+ warning("protocol error: unexpected ref after "
+ "dummy ref, using this ref and continuing anyway");
+
ref = alloc_ref(buffer + GIT_SHA1_HEXSZ + 1);
oidcpy(&ref->old_oid, &old_oid);
*list = ref;
diff --git a/t/t5512-ls-remote.sh b/t/t5512-ls-remote.sh
index 819b9dd..befdfee 100755
--- a/t/t5512-ls-remote.sh
+++ b/t/t5512-ls-remote.sh
@@ -207,5 +207,45 @@ test_expect_success 'ls-remote --symref omits filtered-out matches' '
test_cmp expect actual
'
+test_lazy_prereq GIT_DAEMON '
+ test_tristate GIT_TEST_GIT_DAEMON &&
+ test "$GIT_TEST_GIT_DAEMON" != false
+'
+
+# This test spawns a daemon, so run it only if the user would be OK with
+# testing with git-daemon.
+test_expect_success PIPE,JGIT,GIT_DAEMON 'indicate no refs in standards-compliant empty remote' '
+ JGIT_DAEMON_PORT=${JGIT_DAEMON_PORT-${this_test#t}} &&
+ JGIT_DAEMON_PID= &&
+ git init --bare empty.git &&
+ >empty.git/git-daemon-export-ok &&
+ mkfifo jgit_daemon_output &&
+ {
+ jgit daemon --port="$JGIT_DAEMON_PORT" . >jgit_daemon_output &
+ JGIT_DAEMON_PID=$!
+ } &&
+ test_when_finished kill "$JGIT_DAEMON_PID" &&
+ {
+ read line &&
+ case $line in
+ Exporting*)
+ ;;
+ *)
+ echo "Expected: Exporting" &&
+ false;;
+ esac &&
+ read line &&
+ case $line in
+ "Listening on"*)
+ ;;
+ *)
+ echo "Expected: Listening on" &&
+ false;;
+ esac
+ } <jgit_daemon_output &&
+ # --exit-code asks the command to exit with 2 when no
+ # matching refs are found.
+ test_expect_code 2 git ls-remote --exit-code git://localhost:$JGIT_DAEMON_PORT/empty.git
+'
test_done
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply related
* [PATCH v3 1/2] tests: move test_lazy_prereq JGIT to test-lib.sh
From: Jonathan Tan @ 2016-09-07 23:50 UTC (permalink / raw)
To: git; +Cc: Jonathan Tan, jrnieder, spearce, sbeller, peff, gitster
In-Reply-To: <cover.1473291819.git.jonathantanmy@google.com>
This enables JGIT to be used as a prereq in invocations of
test_expect_success (and other functions) in other test scripts.
Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
---
t/t5310-pack-bitmaps.sh | 4 ----
t/test-lib.sh | 4 ++++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t5310-pack-bitmaps.sh b/t/t5310-pack-bitmaps.sh
index 3893afd..1e376ea 100755
--- a/t/t5310-pack-bitmaps.sh
+++ b/t/t5310-pack-bitmaps.sh
@@ -158,10 +158,6 @@ test_expect_success 'pack with missing parent' '
git pack-objects --stdout --revs <revs >/dev/null
'
-test_lazy_prereq JGIT '
- type jgit
-'
-
test_expect_success JGIT 'we can read jgit bitmaps' '
git clone . compat-jgit &&
(
diff --git a/t/test-lib.sh b/t/test-lib.sh
index d731d66..c9c1037 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1072,6 +1072,10 @@ test_lazy_prereq NOT_ROOT '
test "$uid" != 0
'
+test_lazy_prereq JGIT '
+ type jgit
+'
+
# SANITY is about "can you correctly predict what the filesystem would
# do by only looking at the permission bits of the files and
# directories?" A typical example of !SANITY is running the test
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply related
* [PATCH v3 0/2] handle empty spec-compliant remote repos correctly
From: Jonathan Tan @ 2016-09-07 23:50 UTC (permalink / raw)
To: git; +Cc: Jonathan Tan, jrnieder, spearce, sbeller, peff, gitster
In-Reply-To: <cover.1472836026.git.jonathantanmy@google.com>
Updated, taking into account review comments.
This patch set uses warnings (instead of errors using "die") to indicate
protocol errors that we can recover from. There is a discussion on a sibling
thread about whether such protocol errors should be errors ("die") instead - I
can change it if consensus is that these should be errors.
Jonathan Tan (2):
tests: move test_lazy_prereq JGIT to test-lib.sh
connect: advertized capability is not a ref
connect.c | 17 +++++++++++++++++
t/t5310-pack-bitmaps.sh | 4 ----
t/t5512-ls-remote.sh | 40 ++++++++++++++++++++++++++++++++++++++++
t/test-lib.sh | 4 ++++
4 files changed, 61 insertions(+), 4 deletions(-)
--
2.8.0.rc3.226.g39d4020
^ permalink raw reply
* [PATCH 2/2] diff: remove dead code
From: Stefan Beller @ 2016-09-07 23:36 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
In-Reply-To: <20160907233648.5162-1-sbeller@google.com>
When `len < 1`, len has to be 0 or negative, emit_line will then remove the
first character and by then `len` would be negative. As this doesn't
happen, it is safe to assume it is dead code.
This continues to simplify the code, which was started in b8d9c1a66b
(2009-09-03, diff.c: the builtin_diff() deals with only two-file
comparison).
Signed-off-by: Stefan Beller <sbeller@google.com>
---
diff.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/diff.c b/diff.c
index 79ad91d..c143019 100644
--- a/diff.c
+++ b/diff.c
@@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
return;
}
- if (len < 1) {
- emit_line(o, reset, reset, line, len);
- if (ecbdata->diff_words
- && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
- fputs("~\n", o->file);
- return;
- }
-
if (ecbdata->diff_words) {
if (line[0] == '-') {
diff_words_append(line, len,
--
2.10.0.2.g0676c79.dirty
^ permalink raw reply related
* [PATCH 3/3] diff: remove dead code
From: Stefan Beller @ 2016-09-07 23:36 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
In-Reply-To: <20160907233648.5162-1-sbeller@google.com>
When `len < 1`, len has to be 0 or negative, emit_line will then remove the
first character and by then `len` would be negative. As this doesn't
happen, it is safe to assume it is dead code.
This continues to simplify the code, which was started in b8d9c1a66b
(2009-09-03, diff.c: the builtin_diff() deals with only two-file
comparison).
Signed-off-by: Stefan Beller <sbeller@google.com>
---
diff.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/diff.c b/diff.c
index 79ad91d..c143019 100644
--- a/diff.c
+++ b/diff.c
@@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
return;
}
- if (len < 1) {
- emit_line(o, reset, reset, line, len);
- if (ecbdata->diff_words
- && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
- fputs("~\n", o->file);
- return;
- }
-
if (ecbdata->diff_words) {
if (line[0] == '-') {
diff_words_append(line, len,
--
2.10.0.2.g0676c79.dirty
^ permalink raw reply related
* [PATCH 2/3] diff: omit found pointer from emit_callback
From: Stefan Beller @ 2016-09-07 23:36 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
In-Reply-To: <20160907233648.5162-1-sbeller@google.com>
We keep the actual data in the diff options, which are just as accessible.
Remove the pointer stored in struct emit_callback for readability.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
diff.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 4a6501c..79ad91d 100644
--- a/diff.c
+++ b/diff.c
@@ -354,7 +354,6 @@ struct emit_callback {
const char **label_path;
struct diff_words_data *diff_words;
struct diff_options *opt;
- int *found_changesp;
struct strbuf *header;
};
@@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,
memset(&ecbdata, 0, sizeof(ecbdata));
ecbdata.color_diff = want_color(o->use_color);
- ecbdata.found_changesp = &o->found_changes;
ecbdata.ws_rule = whitespace_rule(name_b);
ecbdata.opt = o;
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
@@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
struct diff_options *o = ecbdata->opt;
const char *line_prefix = diff_line_prefix(o);
+ o->found_changes = 1;
if (ecbdata->header) {
fprintf(o->file, "%s", ecbdata->header->buf);
strbuf_reset(ecbdata->header);
ecbdata->header = NULL;
}
- *(ecbdata->found_changesp) = 1;
if (ecbdata->label_path[0]) {
const char *name_a_tab, *name_b_tab;
@@ -2437,7 +2435,6 @@ static void builtin_diff(const char *name_a,
memset(&ecbdata, 0, sizeof(ecbdata));
ecbdata.label_path = lbl;
ecbdata.color_diff = want_color(o->use_color);
- ecbdata.found_changesp = &o->found_changes;
ecbdata.ws_rule = whitespace_rule(name_b);
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
check_blank_at_eof(&mf1, &mf2, &ecbdata);
--
2.10.0.2.g0676c79.dirty
^ permalink raw reply related
* [PATCH 1/2] diff: omit found pointer from emit_callback
From: Stefan Beller @ 2016-09-07 23:36 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
In-Reply-To: <20160907233648.5162-1-sbeller@google.com>
We keep the actual data in the diff options, which are just as accessible.
Remove the pointer stored in struct emit_callback for readability.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
diff.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 4a6501c..79ad91d 100644
--- a/diff.c
+++ b/diff.c
@@ -354,7 +354,6 @@ struct emit_callback {
const char **label_path;
struct diff_words_data *diff_words;
struct diff_options *opt;
- int *found_changesp;
struct strbuf *header;
};
@@ -722,7 +721,6 @@ static void emit_rewrite_diff(const char *name_a,
memset(&ecbdata, 0, sizeof(ecbdata));
ecbdata.color_diff = want_color(o->use_color);
- ecbdata.found_changesp = &o->found_changes;
ecbdata.ws_rule = whitespace_rule(name_b);
ecbdata.opt = o;
if (ecbdata.ws_rule & WS_BLANK_AT_EOF) {
@@ -1215,13 +1213,13 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
const char *reset = diff_get_color(ecbdata->color_diff, DIFF_RESET);
struct diff_options *o = ecbdata->opt;
const char *line_prefix = diff_line_prefix(o);
+ o->found_changes = 1;
if (ecbdata->header) {
fprintf(o->file, "%s", ecbdata->header->buf);
strbuf_reset(ecbdata->header);
ecbdata->header = NULL;
}
- *(ecbdata->found_changesp) = 1;
if (ecbdata->label_path[0]) {
const char *name_a_tab, *name_b_tab;
@@ -2437,7 +2435,6 @@ static void builtin_diff(const char *name_a,
memset(&ecbdata, 0, sizeof(ecbdata));
ecbdata.label_path = lbl;
ecbdata.color_diff = want_color(o->use_color);
- ecbdata.found_changesp = &o->found_changes;
ecbdata.ws_rule = whitespace_rule(name_b);
if (ecbdata.ws_rule & WS_BLANK_AT_EOF)
check_blank_at_eof(&mf1, &mf2, &ecbdata);
--
2.10.0.2.g0676c79.dirty
^ permalink raw reply related
* [PATCH 1/3] diff.c: use diff_options directly
From: Stefan Beller @ 2016-09-07 23:36 UTC (permalink / raw)
To: gitster; +Cc: git, Stefan Beller
In-Reply-To: <20160907233648.5162-1-sbeller@google.com>
The value of `ecbdata->opt` is accessible via the short variable `o`
already, so let's use that instead.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
diff.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/diff.c b/diff.c
index 534c12e..4a6501c 100644
--- a/diff.c
+++ b/diff.c
@@ -1217,7 +1217,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
const char *line_prefix = diff_line_prefix(o);
if (ecbdata->header) {
- fprintf(ecbdata->opt->file, "%s", ecbdata->header->buf);
+ fprintf(o->file, "%s", ecbdata->header->buf);
strbuf_reset(ecbdata->header);
ecbdata->header = NULL;
}
@@ -1229,9 +1229,9 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
name_a_tab = strchr(ecbdata->label_path[0], ' ') ? "\t" : "";
name_b_tab = strchr(ecbdata->label_path[1], ' ') ? "\t" : "";
- fprintf(ecbdata->opt->file, "%s%s--- %s%s%s\n",
+ fprintf(o->file, "%s%s--- %s%s%s\n",
line_prefix, meta, ecbdata->label_path[0], reset, name_a_tab);
- fprintf(ecbdata->opt->file, "%s%s+++ %s%s%s\n",
+ fprintf(o->file, "%s%s+++ %s%s%s\n",
line_prefix, meta, ecbdata->label_path[1], reset, name_b_tab);
ecbdata->label_path[0] = ecbdata->label_path[1] = NULL;
}
@@ -1249,15 +1249,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
find_lno(line, ecbdata);
emit_hunk_header(ecbdata, line, len);
if (line[len-1] != '\n')
- putc('\n', ecbdata->opt->file);
+ putc('\n', o->file);
return;
}
if (len < 1) {
- emit_line(ecbdata->opt, reset, reset, line, len);
+ emit_line(o, reset, reset, line, len);
if (ecbdata->diff_words
&& ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
- fputs("~\n", ecbdata->opt->file);
+ fputs("~\n", o->file);
return;
}
@@ -1282,8 +1282,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
}
diff_words_flush(ecbdata);
if (ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN) {
- emit_line(ecbdata->opt, context, reset, line, len);
- fputs("~\n", ecbdata->opt->file);
+ emit_line(o, context, reset, line, len);
+ fputs("~\n", o->file);
} else {
/*
* Skip the prefix character, if any. With
@@ -1294,7 +1294,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
line++;
len--;
}
- emit_line(ecbdata->opt, context, reset, line, len);
+ emit_line(o, context, reset, line, len);
}
return;
}
@@ -1316,8 +1316,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
default:
/* incomplete line at the end */
ecbdata->lno_in_preimage++;
- emit_line(ecbdata->opt,
- diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
+ emit_line(o, diff_get_color(ecbdata->color_diff, DIFF_CONTEXT),
reset, line, len);
break;
}
--
2.10.0.2.g0676c79.dirty
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox