Re: [PATCH v2 5/6] git-reflog: add create and exists functions

2015-06-25 Thread Junio C Hamano
David Turner  writes:

Because...???

> These are necessary because ref backends manage reflogs.

"Because ref backends manage reflogs" may be a good explanation to
implement something as part of ref API, but it does not explain why
that something needs to be implemented in the first place.

> In a moment,
> we will use these functions to make git stash work with alternate
> ref backends.
>
> Signed-off-by: David Turner 
> ---
>  builtin/reflog.c | 79 
> +++-
>  1 file changed, 78 insertions(+), 1 deletion(-)
>
> diff --git a/builtin/reflog.c b/builtin/reflog.c
> index c2eb8ff..a64158d 100644
> --- a/builtin/reflog.c
> +++ b/builtin/reflog.c
> @@ -13,6 +13,10 @@ static const char reflog_expire_usage[] =
>  "git reflog expire [--expire=] [--expire-unreachable=] 
> [--rewrite] [--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] 
> ...";
>  static const char reflog_delete_usage[] =
>  "git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] 
> ...";
> +static const char reflog_create_usage[] =
> +"git reflog create ...";

It makes sense to take more than one; you may want to prepare more
than one, and you would signal error by exiting with a non-zero
status if any of them failed.

> +static const char reflog_exists_usage[] =
> +"git reflog exists ...";

This is iffy, though.  "git reflog exists foo bar" says "all of them
exist" or "some of them exist"?  Why is it more useful to implement
"all of them exist"?

Perhaps dropping "..." would be simpler to explain and less
confusing.

> @@ -699,12 +703,79 @@ static int cmd_reflog_delete(int argc, const char 
> **argv, const char *prefix)
>   return status;
>  }
>  
> +static int cmd_reflog_create(int argc, const char **argv, const char *prefix)
> +{
> + int i, status = 0, start = 0;
> + struct strbuf err = STRBUF_INIT;
> +
> + for (i = 1; i < argc; i++) {
> + const char *arg = argv[i];
> + if (!strcmp(arg, "--")) {
> + i++;
> + break;
> + }
> + else if (arg[0] == '-')
> + usage(reflog_create_usage);
> + else
> + break;
> + }
> +
> + start = i;
> +
> + if (argc - start < 1)
> + return error("Nothing to create?");
> +
> + for (i = start ; i < argc; i++) {

s/start ;/start;/ (everywhere).
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git error in tag ...: unterminated header

2015-06-25 Thread Johannes Schindelin
Hi Junio & Wolfgang,

On 2015-06-25 22:24, Junio C Hamano wrote:
> Wolfgang Denk  writes:
> 
>> In message  you wrote:
>>>
>>> > Question is: how can we fix that?
>>>
>>> It could be that 4d0d8975 is buggy and barking at a non breakage.

Well, I would like to believe that this commit made our code *safer* by making 
sure that we would never overrun the buffer. Remember: under certain 
circumstances, the buffer passed to the fsck machinery is *not* terminated by a 
NUL. The code I introduced simply verifies that there is an empty line because 
the fsck code stops there and does not look further.

If the buffer does *not* contain an empty line, the fsck code runs the danger 
of looking beyond the allocated memory because it uses functions that assume 
NUL-terminated strings, while the buffer passed to the fsck code is a counted 
string.

The quick & dirty work-around would be to detect when the buffer does not 
contain an empty line and to make a NUL-terminated copy in that case.

A better solution was outlined by Peff back when I submitted those patches: 
change all the code paths that read objects and make sure that all of them are 
terminated by a NUL. AFAIR some code paths did that already, but not all of 
them.

Ciao,
Dscho
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/6] cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refs

2015-06-25 Thread Junio C Hamano
David Turner  writes:

> Instead of directly writing to and reading from files in
> $GIT_DIR, use ref API to interact with CHERRY_PICK_HEAD
> and REVERT_HEAD.
>
> Signed-off-by: David Turner 
> ---

I may have said this already in the last round, but I cannot shake
off the feeling that this patch is doing two completely unrelated
things at once.

The change to refs.c that introduced the should_autocreate_reflog()
helper (which is a good idea even without any other changes in this
patch) and then using that to commit_ref_update() does not have
anything to do with CHERRY_PICK_HEAD/REVERT_HEAD, does it?

 * commit_ref_update() gained a new "flags" parameter, but it does
   not seem to be used at all.  Why?

 * Why is it a good idea to move the "does the log exist or should
   we auto-create?" check from log_ref_setup() to
   commit_ref_update()?

These are not just unexplained, but does not have anything to do
with using ref API to write and read CHERRY_PICK_HEAD/REVERT_HEAD.

They _might_ be a prerequisite, but it is not clear why.  I suspect
that you do not have to touch refs.c at all for the purpose of the
"theme" of the patch explained by the "Subject" line.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git error in tag ...: unterminated header

2015-06-25 Thread Junio C Hamano
Johannes Schindelin  writes:

> Hi Junio & Wolfgang,
>
> On 2015-06-25 22:24, Junio C Hamano wrote:
>> Wolfgang Denk  writes:
>> 
>>> In message  you wrote:

 > Question is: how can we fix that?

 It could be that 4d0d8975 is buggy and barking at a non breakage.
>
> Well, I would like to believe that this commit made our code *safer*
> by making sure that we would never overrun the buffer. Remember: under
> certain circumstances, the buffer passed to the fsck machinery is
> *not* terminated by a NUL. The code I introduced simply verifies that
> there is an empty line because the fsck code stops there and does not
> look further.
>
> If the buffer does *not* contain an empty line, the fsck code runs the
> danger of looking beyond the allocated memory because it uses
> functions that assume NUL-terminated strings, while the buffer passed
> to the fsck code is a counted string.
>
> The quick & dirty work-around would be to detect when the buffer does
> not contain an empty line and to make a NUL-terminated copy in that
> case.

Yes, I can totally understand its quick-and-dirty-ness would break
a valid case where there is no need for a blank after the header.

> A better solution was outlined by Peff back when I submitted those
> patches: change all the code paths that read objects and make sure
> that all of them are terminated by a NUL. AFAIR some code paths did
> that already, but not all of them.

I do not think you necessarily need a NUL.  As you said, your input
is a counted string, so you know the length of the buffer.  And you
are verifying line by line.  As long as you make sure the buffer
ends with "\n" (instead of saying "it has "\n\n" somewhere),
updating the existing code that does

if (buffer is not well formed wrt "tree")
barf;
else
advance buffer to point at the next line;
if (buffer is not well formed wrt "parent")
barf;
...

to do this instead:

if (buffer is not well formed wrt "tree")
barf;
else
advance buffer to point at the next line;
if (buffer is now beyond the end of the original length)
barf; /* missing "parent" */
if (buffer is not well formed wrt "parent")
barf;
...

shouldn't be rocket science, no?


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 5/5] bisect: allow any terms set by user

2015-06-25 Thread Junio C Hamano
Matthieu Moy  writes:

> +
> +git bisect terms  
> +

The mnemonic for "git bisect start bad good" is Bad comes before
Good (B = 0x42, G = 0x47) and this is same for "new/old", New comes
before Old (N = 0x4e, O = 0x4f).  "git bisect terms new old" follows
the same pattern, which is good.  Easy to remember.

> +This command has to be used before a bisection has started. 
> +must be associated with the latest revisions and  with the
> +ancestors of .

Whoa?  This gets new and old mixed up, doesn't it?

> For example, if something was buggy in the
> +old part of the history, you know somewhere the bug was fixed, and you
> +want to find the exact commit that fixed it, you may want to say `git
> +bisect terms fixed broken`; this way, you would mark a commit that
> +still has the bug with `broken`, and a newer one after the fix with
> +`fixed`.

So, it used to be broken, it got fixed recently, so broken is old,
fixed is new, "bad/new and then good/old" mnemonic says you give
"fixed broken" to "bisect terms".  OK.

> +Only the first bisection following the `git bisect terms` will use the
> +terms. If you mistyped one of the terms you can do again `git bisect
> +terms  `.

This is also the other way around, no?

> +git bisect terms  
> + set up  and  as terms (default: bad, good)

Good.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 5/6] git-reflog: add create and exists functions

2015-06-25 Thread David Turner
On Thu, 2015-06-25 at 16:45 -0400, David Turner wrote:
> +static int cmd_reflog_create(int argc, const char **argv, const char *prefix)
> +{

While revising this patch, I noticed that safe_create_reflog (and this
cmd_reflog_create) only creates reflogs for refs of the form that git
itself would autocreate reflogs for.  In other words, it won't create a
reflog for foo, but will create a reflog for refs/heads/foo (even though
that is very likely to already exist).

So I'll fix that when I re-roll.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Revert "stash: require a clean index to apply"

2015-06-25 Thread Jonathan Kamens
Is this revert going to be applied and released?

Sent from my Android device



-Original Message-
From: Junio C Hamano 
To: Jeff King 
Cc: "bär" , Jonathan Kamens , 
Git List 
Sent: Mon, 15 Jun 2015 4:11 PM
Subject: Re: [PATCH] Revert "stash: require a clean index to apply"

Jeff King  writes:

> Subject: Revert "stash: require a clean index to apply"
>
> This reverts commit ed178ef13a26136d86ff4e33bb7b1afb5033f908.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 5/5] bisect: allow any terms set by user

2015-06-25 Thread Junio C Hamano
Junio C Hamano  writes:

>> +Only the first bisection following the `git bisect terms` will use the
>> +terms. If you mistyped one of the terms you can do again `git bisect
>> +terms  `.

This paragraph may need further polishing.

The first sentence makes it sound as if this is a valid sequence,
but I do not think that is what you meant:

$ git bisect start master maint
$ git bisect bad
$ git bisect terms new old
$ git bisect old
$ git bisect bad

I think what you wanted to say was that "git bisect terms" is in
effect during the single bisect session, and after you are done with
"git bisect reset", the next bisect session, unless you use "git
bisect terms", will use "bad" and "good", as that is the default
pair of terms.

The second sentence may want to be something like

If you mistyped one of the terms, you can do another "git
bisect terms  " to correct them, but
that is possible only before you start the bisection.

Otherwise, you invite this

$ git bisect start master maint
$ git bisect terms new olf
$ git bisect olf
$ git bisect new
$ git bisect old
... error message that says you can give either "new" and "olf"
$ git bisect terms new old
$ git bisect old

which may not work well.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 2/6] cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refs

2015-06-25 Thread David Turner
On Thu, 2015-06-25 at 14:11 -0700, Junio C Hamano wrote:
> David Turner  writes:
> 
> > Instead of directly writing to and reading from files in
> > $GIT_DIR, use ref API to interact with CHERRY_PICK_HEAD
> > and REVERT_HEAD.
> >
> > Signed-off-by: David Turner 
> > ---
> 
> I may have said this already in the last round, but I cannot shake
> off the feeling that this patch is doing two completely unrelated
> things at once.
> 
> The change to refs.c that introduced the should_autocreate_reflog()
> helper (which is a good idea even without any other changes in this
> patch) 

I'll break that out into a separate patch when I reroll.

> and then using that to commit_ref_update() does not have
> anything to do with CHERRY_PICK_HEAD/REVERT_HEAD, does it?

I had thought that it did, but some testing shows that it does not (or
at least does not yet).  The original series of patches was assembled
out of a long process of making the test suite pass with the alternate
ref backend.  I expect that as I rewrite that series, I'll either figure
out what issues these change solved, or remove them.  In this case, I'll
split the patch.

>  * commit_ref_update() gained a new "flags" parameter, but it does
>not seem to be used at all.  Why?

cruft, will remove.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git error in tag ...: unterminated header

2015-06-25 Thread Junio C Hamano
Junio C Hamano  writes:

> Johannes Schindelin  writes:
> ...
>> If the buffer does *not* contain an empty line, the fsck code runs the
>> danger of looking beyond the allocated memory because it uses
>> functions that assume NUL-terminated strings, while the buffer passed
>> to the fsck code is a counted string.
>> that already, but not all of them.
> ...
> I do not think you necessarily need a NUL.  As you said, your input
> is a counted string, so you know the length of the buffer.  And you
> are verifying line by line.  As long as you make sure the buffer
> ends with "\n" (instead of saying "it has "\n\n" somewhere),
> updating the existing code that does ...
> to do this instead: ...
> shouldn't be rocket science, no?

Here is to illustrate what I meant by the above.

I did only the "tag" side (this is on 'maint'), because I did not
want to conflict with a larger change to fsck you have on 'pu'.

I made it use an updated version of require_end_of_header(), which I
named prescan_headers(), as the new sanity check does not require
\n\n as the only end of header, and also the sanity check (both old
and new) also checks for NUL.

I didn't assess how much more involved to make fsck-commit-buffer to
use prescan-headers (and retire require-end-of-header), though.

 fsck.c | 39 ++-
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/fsck.c b/fsck.c
index 10bcb65..7d2d07d 100644
--- a/fsck.c
+++ b/fsck.c
@@ -261,6 +261,29 @@ static int require_end_of_header(const void *data, 
unsigned long size,
return error_func(obj, FSCK_ERROR, "unterminated header");
 }
 
+static int prescan_headers(const void *data, unsigned long size,
+  struct object *obj, fsck_error error_func)
+{
+   const char *buffer = (const char *)data;
+   unsigned long i;
+
+   for (i = 0; i < size; i++) {
+   switch (buffer[i]) {
+   case '\0':
+   return error_func(obj, FSCK_ERROR,
+ "unterminated header: NUL at offset 
%d", i);
+   case '\n':
+   if (i + 1 < size && buffer[i + 1] == '\n')
+   return 0; /* end of header */
+   }
+   }
+
+   /* no blank (i.e. headers and nothing else */
+   if (size && buffer[size - 1] == '\n')
+   return 0;
+   return error_func(obj, FSCK_ERROR, "unterminated header");
+}
+
 static int fsck_ident(const char **ident, struct object *obj, fsck_error 
error_func)
 {
char *end;
@@ -365,6 +388,7 @@ static int fsck_tag_buffer(struct tag *tag, const char 
*data,
unsigned char sha1[20];
int ret = 0;
const char *buffer;
+   const char *end_buffer;
char *to_free = NULL, *eol;
struct strbuf sb = STRBUF_INIT;
 
@@ -387,10 +411,12 @@ static int fsck_tag_buffer(struct tag *tag, const char 
*data,
}
}
 
-   if (require_end_of_header(buffer, size, &tag->object, error_func))
+   end_buffer = buffer + size;
+   if (prescan_headers(buffer, size, &tag->object, error_func))
goto done;
 
-   if (!skip_prefix(buffer, "object ", &buffer)) {
+   if (end_buffer <= buffer ||
+   !skip_prefix(buffer, "object ", &buffer)) {
ret = error_func(&tag->object, FSCK_ERROR, "invalid format - 
expected 'object' line");
goto done;
}
@@ -400,7 +426,8 @@ static int fsck_tag_buffer(struct tag *tag, const char 
*data,
}
buffer += 41;
 
-   if (!skip_prefix(buffer, "type ", &buffer)) {
+   if (end_buffer <= buffer ||
+   !skip_prefix(buffer, "type ", &buffer)) {
ret = error_func(&tag->object, FSCK_ERROR, "invalid format - 
expected 'type' line");
goto done;
}
@@ -415,7 +442,8 @@ static int fsck_tag_buffer(struct tag *tag, const char 
*data,
goto done;
buffer = eol + 1;
 
-   if (!skip_prefix(buffer, "tag ", &buffer)) {
+   if (end_buffer <= buffer ||
+   !skip_prefix(buffer, "tag ", &buffer)) {
ret = error_func(&tag->object, FSCK_ERROR, "invalid format - 
expected 'tag' line");
goto done;
}
@@ -430,7 +458,8 @@ static int fsck_tag_buffer(struct tag *tag, const char 
*data,
   (int)(eol - buffer), buffer);
buffer = eol + 1;
 
-   if (!skip_prefix(buffer, "tagger ", &buffer))
+   if (end_buffer <= buffer ||
+   !skip_prefix(buffer, "tagger ", &buffer))
/* early tags do not contain 'tagger' lines; warn only */
error_func(&tag->object, FSCK_WARN, "invalid format - expected 
'tagger' line");
else


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/6] bisect: use refs infrastructure for BISECT_START

2015-06-25 Thread David Turner
On Thu, 2015-06-25 at 13:52 -0700, Junio C Hamano wrote:
> David Turner  writes:
> 
> > This ref needs to go through the refs backend, since some code assumes
> > that it can be written and read as a ref.
> 
> And the reason why BISECT_HEAD cannot be treated as a ref, but must
> be treated as a file under $GIT_DIR, is...?

After running some tests on the long version of the series, we can and
should move it into the backend; will add a patch to the next reroll

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 04/17] Makefile: a dry-run can error out if no perl. Document the issue

2015-06-25 Thread Philip Oakley

From: "Junio C Hamano" 

"Philip Oakley"  writes:


From: "Junio C Hamano" 


I am not sure what this patch is trying to achieve.


It was probably a bit of 'don't mess with working code', given that
I'd used the NO_PERL solution, rather 'document the issue'


Then this part applies, I think.


If you are not touching what this Makefile actually does, then I
would imagine that you are running the "buildsystems code" that
actually drives 'make -n' with some "available solution" (perhaps
you are running 'make -n NO_PERL=NoThanks' or something like that)?
Then instead of a command like this that nobody would read in this
file, the same command can instead go there to explain what the
"workaround" (e.g. unusual-looking 'make -n NO_PERL=NoThanks') is
doing?



I was more of the view that this was about prevention (here), rather
than retrospective explanation of the code (there).

In my case the errors were showing problems with the PM.stamp in the
makefile (I didn't have the solution at that point).

So either a short comment "#  consider using 'NO_PERL=YesPlease' for dry
run invocations" (beware your double negative ;-), or the addition of
the '+recipe', would still be my preferred change, rather than leaving
the open manhole for others to fall into.

The thread on my difficulties is at $gmane/263656 (2015-02-10 22:51)
"
   At the moment I'm getting (on my old WinXP machine, using Msysgit
   1.9.5 as a basis)

   $ make -n MSVC=1 V=1 1>makedry.txt
   make[1]: *** No rule to make target `PM.stamp', needed by 
`perl.mak'.

   Stop.
   make: *** [perl/perl.mak] Error 2
"
As you can see, at that time the place to look would be the makefile,
so I would do think a 'fix' there would still be appropriate.

Do you have a preference among the three options (comment, +recipe, 
drop)?

--
Philip

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 3/6] bisect: use refs infrastructure for BISECT_START

2015-06-25 Thread David Turner
On Thu, 2015-06-25 at 19:21 -0400, David Turner wrote:
> On Thu, 2015-06-25 at 13:52 -0700, Junio C Hamano wrote:
> > David Turner  writes:
> > 
> > > This ref needs to go through the refs backend, since some code assumes
> > > that it can be written and read as a ref.
> > 
> > And the reason why BISECT_HEAD cannot be treated as a ref, but must
> > be treated as a file under $GIT_DIR, is...?
> 
> After running some tests on the long version of the series, we can and
> should move it into the backend; will add a patch to the next reroll

Actually, I've looked into this further. BISECT_START isn't a ref
because it contains the ref name that the bisection started from (not a
symbolic ref).  BISECT_HEAD is a ref.  Will fix.

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Revert "stash: require a clean index to apply"

2015-06-25 Thread Jeff King
On Thu, Jun 25, 2015 at 05:49:11PM -0400, Jonathan Kamens wrote:

> Is this revert going to be applied and released?

It is on "master", and part of v2.5.0-rc0 (it is not part of v2.4.x, because
the original problem was not there, either).

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/7] refs.c: add err arguments to reflog functions

2015-06-25 Thread David Turner
Add an err argument to log_ref_setup that can explain the reason
for a failure. This then eliminates the need to manage errno through
this function since we can just add strerror(errno) to the err string
when meaningful. No callers relied on errno from this function for
anything else than the error message.

Also add err arguments to private functions write_ref_to_lockfile,
log_ref_write_1, commit_ref_update. This again eliminates the need to
manage errno in these functions.

Update of a patch by Ronnie Sahlberg.

Signed-off-by: Ronnie Sahlberg 
Signed-off-by: David Turner 
---
 builtin/checkout.c |   8 ++--
 refs.c | 111 -
 refs.h |   4 +-
 3 files changed, 66 insertions(+), 57 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index c018ab3..93f63d3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -624,16 +624,18 @@ static void update_refs_for_switch(const struct 
checkout_opts *opts,
struct strbuf log_file = STRBUF_INIT;
int ret;
const char *ref_name;
+   struct strbuf err = STRBUF_INIT;
 
ref_name = mkpath("refs/heads/%s", 
opts->new_orphan_branch);
temp = log_all_ref_updates;
log_all_ref_updates = 1;
-   ret = log_ref_setup(ref_name, &log_file);
+   ret = log_ref_setup(ref_name, &log_file, &err);
log_all_ref_updates = temp;
strbuf_release(&log_file);
if (ret) {
-   fprintf(stderr, _("Can not do reflog 
for '%s'\n"),
-   opts->new_orphan_branch);
+   fprintf(stderr, _("Can not do reflog 
for '%s'. %s\n"),
+   opts->new_orphan_branch, 
err.buf);
+   strbuf_release(&err);
return;
}
}
diff --git a/refs.c b/refs.c
index fb568d7..b34a54a 100644
--- a/refs.c
+++ b/refs.c
@@ -2975,9 +2975,11 @@ static int rename_ref_available(const char *oldname, 
const char *newname)
return ret;
 }
 
-static int write_ref_to_lockfile(struct ref_lock *lock, const unsigned char 
*sha1);
+static int write_ref_to_lockfile(struct ref_lock *lock,
+const unsigned char *sha1, struct strbuf* err);
 static int commit_ref_update(struct ref_lock *lock,
-const unsigned char *sha1, const char *logmsg);
+const unsigned char *sha1, const char *logmsg,
+struct strbuf *err);
 
 int rename_ref(const char *oldrefname, const char *newrefname, const char 
*logmsg)
 {
@@ -3038,9 +3040,10 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
}
hashcpy(lock->old_oid.hash, orig_sha1);
 
-   if (write_ref_to_lockfile(lock, orig_sha1) ||
-   commit_ref_update(lock, orig_sha1, logmsg)) {
-   error("unable to write current sha1 into %s", newrefname);
+   if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
+   commit_ref_update(lock, orig_sha1, logmsg, &err)) {
+   error("unable to write current sha1 into %s: %s", newrefname, 
err.buf);
+   strbuf_release(&err);
goto rollback;
}
 
@@ -3056,9 +3059,11 @@ int rename_ref(const char *oldrefname, const char 
*newrefname, const char *logms
 
flag = log_all_ref_updates;
log_all_ref_updates = 0;
-   if (write_ref_to_lockfile(lock, orig_sha1) ||
-   commit_ref_update(lock, orig_sha1, NULL))
-   error("unable to write current sha1 into %s", oldrefname);
+   if (write_ref_to_lockfile(lock, orig_sha1, &err) ||
+   commit_ref_update(lock, orig_sha1, NULL, &err)) {
+   error("unable to write current sha1 into %s: %s", oldrefname, 
err.buf);
+   strbuf_release(&err);
+   }
log_all_ref_updates = flag;
 
  rollbacklog:
@@ -3113,8 +3118,8 @@ static int copy_msg(char *buf, const char *msg)
return cp - buf;
 }
 
-/* This function must set a meaningful errno on failure */
-int log_ref_setup(const char *refname, struct strbuf *sb_logfile)
+/* This function will fill in *err and return -1 on failure */
+int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct 
strbuf *err)
 {
int logfd, oflags = O_APPEND | O_WRONLY;
char *logfile;
@@ -3129,9 +3134,8 @@ int log_ref_setup(const char *refname, struct strbuf 
*sb_logfile)
 starts_with(refname, "refs/notes/") ||
 !strcmp(refname, "HEAD

[PATCH v3 6/7] git-reflog: add create and exists functions

2015-06-25 Thread David Turner
These are necessary because alternate ref backends might store reflogs
somewhere other than .git/logs.  Code that now directly manipulates
.git/logs should instead go through git-reflog.

In a moment, we will use these functions to make git stash work with
alternate ref backends.

Signed-off-by: David Turner 
---
 builtin/reflog.c   | 79 +-
 t/t1411-reflog-show.sh | 12 
 2 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/builtin/reflog.c b/builtin/reflog.c
index c2eb8ff..7fe31fa 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -13,6 +13,10 @@ static const char reflog_expire_usage[] =
 "git reflog expire [--expire=] [--expire-unreachable=] [--rewrite] 
[--updateref] [--stale-fix] [--dry-run | -n] [--verbose] [--all] ...";
 static const char reflog_delete_usage[] =
 "git reflog delete [--rewrite] [--updateref] [--dry-run | -n] [--verbose] 
...";
+static const char reflog_create_usage[] =
+"git reflog create ...";
+static const char reflog_exists_usage[] =
+"git reflog exists ";
 
 static unsigned long default_reflog_expire;
 static unsigned long default_reflog_expire_unreachable;
@@ -699,12 +703,79 @@ static int cmd_reflog_delete(int argc, const char **argv, 
const char *prefix)
return status;
 }
 
+static int cmd_reflog_create(int argc, const char **argv, const char *prefix)
+{
+   int i, status = 0, start = 0;
+   struct strbuf err = STRBUF_INIT;
+   int temp;
+
+   for (i = 1; i < argc; i++) {
+   const char *arg = argv[i];
+   if (!strcmp(arg, "--")) {
+   i++;
+   break;
+   }
+   else if (arg[0] == '-')
+   usage(reflog_create_usage);
+   else
+   break;
+   }
+
+   start = i;
+
+   if (argc - start < 1)
+   return error("Nothing to create?");
+
+   temp = log_all_ref_updates;
+   log_all_ref_updates = 1;
+   for (i = start; i < argc; i++) {
+   if (check_refname_format(argv[i], REFNAME_ALLOW_ONELEVEL))
+   die("invalid ref format: %s", argv[i]);
+   }
+   for (i = start; i < argc; i++) {
+   if (safe_create_reflog(argv[i], &err, 1)) {
+   error("could not create reflog %s: %s", argv[i],
+ err.buf);
+   status = 1;
+   strbuf_release(&err);
+   }
+   }
+   log_all_ref_updates = temp;
+   return status;
+}
+
+static int cmd_reflog_exists(int argc, const char **argv, const char *prefix)
+{
+   int i, status = 0, start = 0;
+
+   for (i = 1; i < argc; i++) {
+   const char *arg = argv[i];
+   if (!strcmp(arg, "--")) {
+   i++;
+   break;
+   }
+   else if (arg[0] == '-')
+   usage(reflog_exists_usage);
+   else
+   break;
+   }
+
+   start = i;
+
+   if (argc - start != 1)
+   usage(reflog_exists_usage);
+
+   if (check_refname_format(argv[start], REFNAME_ALLOW_ONELEVEL))
+   die("invalid ref format: %s", argv[start]);
+   return !reflog_exists(argv[start]);
+}
+
 /*
  * main "reflog"
  */
 
 static const char reflog_usage[] =
-"git reflog [ show | expire | delete ]";
+"git reflog [ show | expire | delete | create | exists ]";
 
 int cmd_reflog(int argc, const char **argv, const char *prefix)
 {
@@ -724,5 +795,11 @@ int cmd_reflog(int argc, const char **argv, const char 
*prefix)
if (!strcmp(argv[1], "delete"))
return cmd_reflog_delete(argc - 1, argv + 1, prefix);
 
+   if (!strcmp(argv[1], "create"))
+   return cmd_reflog_create(argc - 1, argv + 1, prefix);
+
+   if (!strcmp(argv[1], "exists"))
+   return cmd_reflog_exists(argc - 1, argv + 1, prefix);
+
return cmd_log_reflog(argc, argv, prefix);
 }
diff --git a/t/t1411-reflog-show.sh b/t/t1411-reflog-show.sh
index 6f47c0d..6e1abe7 100755
--- a/t/t1411-reflog-show.sh
+++ b/t/t1411-reflog-show.sh
@@ -166,4 +166,16 @@ test_expect_success 'git log -g -p shows diffs vs. 
parents' '
test_cmp expect actual
 '
 
+test_expect_success 'reflog exists works' '
+   git reflog exists refs/heads/master &&
+   ! git reflog exists refs/heads/nonexistent
+'
+
+test_expect_success 'reflog create works' '
+   git update-ref non-refs-dir HEAD &&
+   ! git reflog exists non-refs-dir &&
+   git reflog create non-refs-dir &&
+   git reflog exists non-refs-dir
+'
+
 test_done
-- 
2.0.4.314.gdbf7a51-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/7] bisect: treat BISECT_HEAD as a ref

2015-06-25 Thread David Turner
Instead of directly writing to and reading from files in
$GIT_DIR, use ref API to interact with BISECT_HEAD.

Signed-off-by: David Turner 
---
 git-bisect.sh | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/git-bisect.sh b/git-bisect.sh
index ae3fec2..dddcc89 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -35,7 +35,7 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 
 bisect_head()
 {
-   if test -f "$GIT_DIR/BISECT_HEAD"
+   if bisect_head_exists
then
echo BISECT_HEAD
else
@@ -209,6 +209,10 @@ check_expected_revs() {
done
 }
 
+bisect_head_exists() {
+git rev-parse --quiet --verify "BISECT_HEAD" >/dev/null
+}
+
 bisect_skip() {
all=''
for arg in "$@"
@@ -310,7 +314,7 @@ bisect_next() {
bisect_next_check good
 
# Perform all bisection computation, display and checkout
-   git bisect--helper --next-all $(test -f "$GIT_DIR/BISECT_HEAD" && echo 
--no-checkout)
+   git bisect--helper --next-all $(bisect_head_exists && echo 
--no-checkout)
res=$?
 
# Check if we should exit because bisection is finished
@@ -377,7 +381,7 @@ bisect_reset() {
usage ;;
esac
 
-   if ! test -f "$GIT_DIR/BISECT_HEAD" && ! git checkout "$branch" --
+   if ! bisect_head_exists && ! git checkout "$branch" --
then
die "$(eval_gettext "Could not check out original HEAD 
'\$branch'.
 Try 'git bisect reset '.")"
-- 
2.0.4.314.gdbf7a51-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/7] refs: Break out check for reflog autocreation

2015-06-25 Thread David Turner
This is just for clarity.

Signed-off-by: David Turner 
---
 refs.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/refs.c b/refs.c
index b34a54a..dff91cf 100644
--- a/refs.c
+++ b/refs.c
@@ -3118,6 +3118,14 @@ static int copy_msg(char *buf, const char *msg)
return cp - buf;
 }
 
+static int should_autocreate_reflog(const char *refname)
+{
+   return starts_with(refname, "refs/heads/") ||
+   starts_with(refname, "refs/remotes/") ||
+   starts_with(refname, "refs/notes/") ||
+   !strcmp(refname, "HEAD");
+}
+
 /* This function will fill in *err and return -1 on failure */
 int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct 
strbuf *err)
 {
@@ -3128,11 +3136,7 @@ int log_ref_setup(const char *refname, struct strbuf 
*sb_logfile, struct strbuf
logfile = sb_logfile->buf;
/* make sure the rest of the function can't change "logfile" */
sb_logfile = NULL;
-   if (log_all_ref_updates &&
-   (starts_with(refname, "refs/heads/") ||
-starts_with(refname, "refs/remotes/") ||
-starts_with(refname, "refs/notes/") ||
-!strcmp(refname, "HEAD"))) {
+   if (log_all_ref_updates && should_autocreate_reflog(refname)) {
if (safe_create_leading_directories(logfile) < 0) {
strbuf_addf(err, "unable to create directory for %s. "
"%s", logfile, strerror(errno));
-- 
2.0.4.314.gdbf7a51-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 7/7] git-stash: use git-reflog instead of creating files

2015-06-25 Thread David Turner
This is in support of alternate ref backends which don't necessarily
store reflogs as files.

Signed-off-by: David Turner 
---
 git-stash.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-stash.sh b/git-stash.sh
index 8e9e2cd..27155bc 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -184,7 +184,7 @@ store_stash () {
fi
 
# Make sure the reflog for stash is kept.
-   : >>"$(git rev-parse --git-path logs/$ref_stash)"
+   git reflog create "$ref_stash"
git update-ref -m "$stash_msg" $ref_stash $w_commit
ret=$?
test $ret != 0 && test -z $quiet &&
@@ -262,7 +262,7 @@ save_stash () {
say "$(gettext "No local changes to save")"
exit 0
fi
-   test -f "$(git rev-parse --git-path logs/$ref_stash)" ||
+   git reflog exists $ref_stash ||
clear_stash || die "$(gettext "Cannot initialize stash")"
 
create_stash "$stash_msg" $untracked
-- 
2.0.4.314.gdbf7a51-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 5/7] refs: add safe_create_reflog function

2015-06-25 Thread David Turner
Make log_ref_setup private, and add public safe_create_reflog which
calls log_ref_setup.

In a moment, we will use safe_create_reflog to add reflog creation
commands to git-reflog.

Signed-off-by: David Turner 
---
 builtin/checkout.c |  4 +---
 refs.c | 19 ---
 refs.h |  2 +-
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 93f63d3..55e4fbc 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -621,7 +621,6 @@ static void update_refs_for_switch(const struct 
checkout_opts *opts,
if (opts->new_orphan_branch) {
if (opts->new_branch_log && !log_all_ref_updates) {
int temp;
-   struct strbuf log_file = STRBUF_INIT;
int ret;
const char *ref_name;
struct strbuf err = STRBUF_INIT;
@@ -629,9 +628,8 @@ static void update_refs_for_switch(const struct 
checkout_opts *opts,
ref_name = mkpath("refs/heads/%s", 
opts->new_orphan_branch);
temp = log_all_ref_updates;
log_all_ref_updates = 1;
-   ret = log_ref_setup(ref_name, &log_file, &err);
+   ret = safe_create_reflog(ref_name, &err, 0);
log_all_ref_updates = temp;
-   strbuf_release(&log_file);
if (ret) {
fprintf(stderr, _("Can not do reflog 
for '%s'. %s\n"),
opts->new_orphan_branch, 
err.buf);
diff --git a/refs.c b/refs.c
index dff91cf..7519dac 100644
--- a/refs.c
+++ b/refs.c
@@ -3123,11 +3123,12 @@ static int should_autocreate_reflog(const char *refname)
return starts_with(refname, "refs/heads/") ||
starts_with(refname, "refs/remotes/") ||
starts_with(refname, "refs/notes/") ||
+   !strcmp(refname, "refs/stash") ||
!strcmp(refname, "HEAD");
 }
 
 /* This function will fill in *err and return -1 on failure */
-int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct 
strbuf *err)
+static int log_ref_setup(const char *refname, struct strbuf *sb_logfile, 
struct strbuf *err, int force_create)
 {
int logfd, oflags = O_APPEND | O_WRONLY;
char *logfile;
@@ -3136,7 +3137,8 @@ int log_ref_setup(const char *refname, struct strbuf 
*sb_logfile, struct strbuf
logfile = sb_logfile->buf;
/* make sure the rest of the function can't change "logfile" */
sb_logfile = NULL;
-   if (log_all_ref_updates && should_autocreate_reflog(refname)) {
+   if (log_all_ref_updates &&
+   (force_create || should_autocreate_reflog(refname))) {
if (safe_create_leading_directories(logfile) < 0) {
strbuf_addf(err, "unable to create directory for %s. "
"%s", logfile, strerror(errno));
@@ -3171,6 +3173,17 @@ int log_ref_setup(const char *refname, struct strbuf 
*sb_logfile, struct strbuf
return 0;
 }
 
+
+int safe_create_reflog(const char *refname, struct strbuf *err, int 
force_create)
+{
+   int ret;
+   struct strbuf sb = STRBUF_INIT;
+
+   ret = log_ref_setup(refname, &sb, err, force_create);
+   strbuf_release(&sb);
+   return ret;
+}
+
 static int log_ref_write_fd(int fd, const unsigned char *old_sha1,
const unsigned char *new_sha1,
const char *committer, const char *msg)
@@ -3207,7 +3220,7 @@ static int log_ref_write_1(const char *refname, const 
unsigned char *old_sha1,
if (log_all_ref_updates < 0)
log_all_ref_updates = !is_bare_repository();
 
-   result = log_ref_setup(refname, sb_log_file, err);
+   result = log_ref_setup(refname, sb_log_file, err, 0);
 
if (result)
return result;
diff --git a/refs.h b/refs.h
index debdefc..3b90e16 100644
--- a/refs.h
+++ b/refs.h
@@ -228,7 +228,7 @@ int pack_refs(unsigned int flags);
 /*
  * Setup reflog before using. Fill in err and return -1 on failure.
  */
-int log_ref_setup(const char *refname, struct strbuf *logfile, struct strbuf 
*err);
+int safe_create_reflog(const char *refname, struct strbuf *err, int 
force_create);
 
 /** Reads log for the value of ref during at_time. **/
 extern int read_ref_at(const char *refname, unsigned int flags,
-- 
2.0.4.314.gdbf7a51-twtrsrc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 2/7] cherry-pick: treat CHERRY_PICK_HEAD and REVERT_HEAD as refs

2015-06-25 Thread David Turner
Instead of directly writing to and reading from files in
$GIT_DIR, use ref API to interact with CHERRY_PICK_HEAD
and REVERT_HEAD.

Signed-off-by: David Turner 
---
 branch.c |  4 ++--
 builtin/commit.c |  6 +++---
 builtin/merge.c  |  2 +-
 contrib/completion/git-prompt.sh |  4 ++--
 git-gui/lib/commit.tcl   |  2 +-
 sequencer.c  | 37 +++--
 t/t7509-commit.sh|  4 ++--
 wt-status.c  |  6 ++
 8 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/branch.c b/branch.c
index b002435..ec598aa 100644
--- a/branch.c
+++ b/branch.c
@@ -302,8 +302,8 @@ void create_branch(const char *head,
 
 void remove_branch_state(void)
 {
-   unlink(git_path("CHERRY_PICK_HEAD"));
-   unlink(git_path("REVERT_HEAD"));
+   delete_ref("CHERRY_PICK_HEAD", NULL, REF_NODEREF);
+   delete_ref("REVERT_HEAD", NULL, REF_NODEREF);
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_RR"));
unlink(git_path("MERGE_MSG"));
diff --git a/builtin/commit.c b/builtin/commit.c
index b5b1158..53c7e90 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -168,7 +168,7 @@ static void determine_whence(struct wt_status *s)
 {
if (file_exists(git_path("MERGE_HEAD")))
whence = FROM_MERGE;
-   else if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
+   else if (ref_exists("CHERRY_PICK_HEAD")) {
whence = FROM_CHERRY_PICK;
if (file_exists(git_path(SEQ_DIR)))
sequencer_in_use = 1;
@@ -1777,8 +1777,8 @@ int cmd_commit(int argc, const char **argv, const char 
*prefix)
}
ref_transaction_free(transaction);
 
-   unlink(git_path("CHERRY_PICK_HEAD"));
-   unlink(git_path("REVERT_HEAD"));
+   delete_ref("CHERRY_PICK_HEAD", NULL, REF_NODEREF);
+   delete_ref("REVERT_HEAD", NULL, REF_NODEREF);
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
unlink(git_path("MERGE_MODE"));
diff --git a/builtin/merge.c b/builtin/merge.c
index 46aacd6..3e2ae2f 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -1206,7 +1206,7 @@ int cmd_merge(int argc, const char **argv, const char 
*prefix)
else
die(_("You have not concluded your merge (MERGE_HEAD 
exists)."));
}
-   if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
+   if (ref_exists("CHERRY_PICK_HEAD")) {
if (advice_resolve_conflict)
die(_("You have not concluded your cherry-pick 
(CHERRY_PICK_HEAD exists).\n"
"Please, commit your changes before you merge."));
diff --git a/contrib/completion/git-prompt.sh b/contrib/completion/git-prompt.sh
index 366f0bc..e2c5583 100644
--- a/contrib/completion/git-prompt.sh
+++ b/contrib/completion/git-prompt.sh
@@ -415,9 +415,9 @@ __git_ps1 ()
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
-   elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
+   elif git rev-parse --quiet --verify "CHERRY_PICK_HEAD" 
>/dev/null; then
r="|CHERRY-PICKING"
-   elif [ -f "$g/REVERT_HEAD" ]; then
+   elif git rev-parse --quiet --verify "REVERT_HEAD" >/dev/null; 
then
r="|REVERTING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
index 864b687..2b08b13 100644
--- a/git-gui/lib/commit.tcl
+++ b/git-gui/lib/commit.tcl
@@ -409,7 +409,7 @@ A rescan will be automatically started now.
catch {file delete [gitdir MERGE_MSG]}
catch {file delete [gitdir SQUASH_MSG]}
catch {file delete [gitdir GITGUI_MSG]}
-   catch {file delete [gitdir CHERRY_PICK_HEAD]}
+   catch {git update-ref -d --no-deref CHERRY_PICK_HEAD}
 
# -- Let rerere do its thing.
#
diff --git a/sequencer.c b/sequencer.c
index f8421a8..de904aa 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -160,19 +160,20 @@ static void free_message(struct commit *commit, struct 
commit_message *msg)
 
 static void write_cherry_pick_head(struct commit *commit, const char 
*pseudoref)
 {
-   const char *filename;
-   int fd;
-   struct strbuf buf = STRBUF_INIT;
+   struct strbuf err = STRBUF_INIT;
+   void *transaction;
 
-   strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
+   transaction = ref_transaction_begin(&err);
+   if (!transaction)
+   die(_("Could not create transaction: %s"), err.buf);
 
-   filename = git_path("%s", pseudoref);
-   fd = open(filename, O_WRONLY | O_CREAT, 0666);
-   if (fd < 0)
-   die_errno(_("Could not open '%s' for writing"), filename);
-   if (write_in_full(fd, buf.buf, buf.len) != buf.len || cl

git submodule init --recursive?

2015-06-25 Thread Robert Dailey
I have a few nested submodules, all use relative URLs such as:

../mysubmodule.git
../../tools/tool1.git

If I change my parent repo URL, I need to recursively update all
remotes in each submodule. There is no `--recursive` option for `git
submodule init`. What is the recommend method for accomplishing this?

Thanks in advance.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: git submodule init --recursive?

2015-06-25 Thread Robert Dailey
On Thu, Jun 25, 2015 at 8:04 PM, Robert Dailey  wrote:
> I have a few nested submodules, all use relative URLs such as:
>
> ../mysubmodule.git
> ../../tools/tool1.git
>
> If I change my parent repo URL, I need to recursively update all
> remotes in each submodule. There is no `--recursive` option for `git
> submodule init`. What is the recommend method for accomplishing this?
>
> Thanks in advance.

Never mind please, I'm a moron. I'm supposed to use sync for this task.

Been a long day and haven't had enough beer yet.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Revert "stash: require a clean index to apply"

2015-06-25 Thread Jonathan Kamens

Um.

I encountered this issue in git 2.4.3 on Fedora 22.

These lines appear in /usr/libexec/git-core/git-stash on my Fedora 22 
system:


git diff-index --cached --quiet --ignore-submodules HEAD -- ||
die "$(gettext "Cannot apply stash: Your index contains 
uncommitted changes.")"


They also appear in 
https://github.com/git/git/blob/69f9a6e54a46c4a75dff680047a465d04cca20ca/git-stash.sh#L445 
, which is the commit tagged v2.4.3.


In fact, it appears they were released in v2.4.2, at least according to 
https://github.com/git/git/compare/v2.4.1...v2.4.2 .


So it appears to me that this patch was, in fact, released in v2.4.x and 
therefore needs to be reverted in v2.4.x.


  jik

On 06/25/2015 08:27 PM, Jeff King wrote:

On Thu, Jun 25, 2015 at 05:49:11PM -0400, Jonathan Kamens wrote:


Is this revert going to be applied and released?

It is on "master", and part of v2.5.0-rc0 (it is not part of v2.4.x, because
the original problem was not there, either).

-Peff


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Revert "stash: require a clean index to apply"

2015-06-25 Thread Jeff King
On Thu, Jun 25, 2015 at 09:12:55PM -0400, Jonathan Kamens wrote:

> I encountered this issue in git 2.4.3 on Fedora 22.

Ah, sorry, you're right. I must have fed the wrong sha1 to "git tag
--contains" earlier.

I agree it can probably go onto the v2.4.x maintenance track. It is
already in v2.5.0-rc0.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 4/5] bisect: add the terms old/new

2015-06-25 Thread Christian Couder
On Thu, Jun 25, 2015 at 8:50 PM, Matthieu Moy  wrote:

[...]

> @@ -178,7 +183,7 @@ bisect_start() {
> } &&
> git rev-parse --sq-quote "$@" >"$GIT_DIR/BISECT_NAMES" &&
> eval "$eval true" &&
> -   if test $revision_seen -eq 1 && test ! -s "$GIT_DIR/BISECT_TERMS"
> +   if test $must_write_terms -eq 1 && test ! -s "$GIT_DIR/BISECT_TERMS"
> then
> echo "$NAME_BAD" >"$GIT_DIR/BISECT_TERMS" &&
> echo "$NAME_GOOD" >>"$GIT_DIR/BISECT_TERMS"

You are writing BISECT_TERMS here...

> @@ -543,14 +548,22 @@ check_and_set_terms () {
> fi
> NAME_BAD="bad"
> NAME_GOOD="good" ;;
> +   new|old)
> +   if ! test -s "$GIT_DIR/BISECT_TERMS"
> +   then
> +   echo "new" >"$GIT_DIR/BISECT_TERMS" &&
> +   echo "old" >>"$GIT_DIR/BISECT_TERMS"
> +   fi
> +   NAME_BAD="new"
> +   NAME_GOOD="old" ;;

...and here nearly in the same way.

So perhaps you could use a function like:

write_bisect_terms() {
  if test ! -s "$GIT_DIR/BISECT_TERMS"
  then
echo "$NAME_BAD" >"$GIT_DIR/BISECT_TERMS" &&
echo "$NAME_GOOD" >>"$GIT_DIR/BISECT_TERMS"
  fi
}
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] Revert "stash: require a clean index to apply"

2015-06-25 Thread Junio C Hamano
On Thu, Jun 25, 2015 at 9:03 PM, Jeff King  wrote:
> On Thu, Jun 25, 2015 at 09:12:55PM -0400, Jonathan Kamens wrote:
>
>> I encountered this issue in git 2.4.3 on Fedora 22.
>
> Ah, sorry, you're right. I must have fed the wrong sha1 to "git tag
> --contains" earlier.
>
> I agree it can probably go onto the v2.4.x maintenance track. It is
> already in v2.5.0-rc0.

Yeah, thanks for clarifying while I was away. As with any other changes,
a revert also follows the "master first and then maintenance tracks later"
pattern. Perhaps in 2.4.6 which I expect we would do during the 2.5-rc
period.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 7/7] cat-file: add --batch-all-objects option

2015-06-25 Thread Eric Sunshine
On Mon, Jun 22, 2015 at 6:45 AM, Jeff King  wrote:
> [...] This patch adds an option to
> "cat-file --batch-check" to operate on all available
> objects (rather than reading names from stdin).
>
> Signed-off-by: Jeff King 
> ---
> diff --git a/t/t1006-cat-file.sh b/t/t1006-cat-file.sh
> index 93a4794..2b4220a 100755
> --- a/t/t1006-cat-file.sh
> +++ b/t/t1006-cat-file.sh
> @@ -547,4 +547,31 @@ test_expect_success 'git cat-file --batch 
> --follow-symlink returns correct sha a
> test_cmp expect actual
>  '
>
> +test_expect_success 'cat-file --batch-all-objects shows all objects' '
> +   # make new repos so we now the full set of objects; we will

s/now/know/

> +   # also make sure that there are some packed and some loose
> +   # objects, some referenced and some not, and that there are
> +   # some available only via alternates.
> +   git init all-one &&
> +   (
> +   cd all-one &&
> +   echo content >file &&
> +   git add file &&
> +   git commit -qm base &&
> +   git rev-parse HEAD HEAD^{tree} HEAD:file &&
> +   git repack -ad &&
> +   echo not-cloned | git hash-object -w --stdin
> +   ) >expect.unsorted &&
> +   git clone -s all-one all-two &&
> +   (
> +   cd all-two &&
> +   echo local-unref | git hash-object -w --stdin
> +   ) >>expect.unsorted &&
> +   sort expect &&
> +   git -C all-two cat-file --batch-all-objects \
> +   --batch-check="%(objectname)" 
> >actual.unsorted &&
> +   sort actual &&
> +   test_cmp expect actual
> +'
> +
>  test_done
> --
> 2.4.4.719.g3984bc6
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v9 5/5] bisect: allow any terms set by user

2015-06-25 Thread Matthieu Moy
Junio C Hamano  writes:

> Matthieu Moy  writes:
>
>> +
>> +git bisect terms  
>> +
>
> The mnemonic for "git bisect start bad good" is Bad comes before
> Good (B = 0x42, G = 0x47) and this is same for "new/old", New comes
> before Old (N = 0x4e, O = 0x4f).  "git bisect terms new old" follows
> the same pattern, which is good.  Easy to remember.
>
>> +This command has to be used before a bisection has started. 
>> +must be associated with the latest revisions and  with the
>> +ancestors of .
>
> Whoa?  This gets new and old mixed up, doesn't it?

Right. I think it was already the case before, but using term1/term2 in
the text made it hard to spot. The new wording is clearer, and makes it
easier to find bugs in the explanations ;-).

>> +Only the first bisection following the `git bisect terms` will use the
>> +terms. If you mistyped one of the terms you can do again `git bisect
>> +terms  `.
>
> This is also the other way around, no?

Indeed.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


<    1   2