* Re: [PATCH] t4018: introduce test cases for the internal hunk header patterns
From: Junio C Hamano @ 2011-12-19 23:17 UTC (permalink / raw)
To: Brandon Casey; +Cc: Brandon Casey, peff, git, j6t, jrnieder
In-Reply-To: <CA+sFfMeogJ==ud6NdPj_KZFUKFeB--RBmPkLndjrQwhg15V5ig@mail.gmail.com>
Brandon Casey <drafnel@gmail.com> writes:
>> * after the line that contains "RIGHT" token, there should be one (and
>> only one) line that contains "ChangeMe". The test modifies this
>> token to "IWasChanged", compares the original with the modified
>> result, and expects the "RIGHT" token above appears on the hunk
>> header.
>
> Both good improvements.
Let's not call "ChangeMe" a *token*, as I think the easiest example would
look like the following and it would not use it as such. Rephrasing it as
a "string" would be better.
@@ ... @@ int RIGHT_function_hunk_header(void)
int RIGHT_function_hunk_header(void)
{
- const char *msg = "ChangeME";
+ const char *msg = "IWasChanged";
printf("Hello, world, %s\n", msg);
return 0;
}
@@ ...
^ permalink raw reply
* Re: [PATCH] t4018: introduce test cases for the internal hunk header patterns
From: Brandon Casey @ 2011-12-19 22:57 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Brandon Casey, peff, git, j6t, jrnieder
In-Reply-To: <7vty4wkx19.fsf@alter.siamese.dyndns.org>
On Mon, Dec 19, 2011 at 4:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Brandon Casey <casey@nrlssc.navy.mil> writes:
>> * test cases must provide a function named "RIGHT_function_hunk_header"
>> - this is the function name that should appear on the hunk header line
>> - the body of this function should have an assignment like
>>
>> answer = 0
>>
>> The test suite will modify the above line to produce a difference
>> from the original. Additionally, this should be far enough within
>> the body of the function so that the function name is not part of
>> the lines of context.
>
> Although I do not think of any language with a syntax rule where that the
> overlong RIGHT_func... token is an illegal symbol offhand, this feels a
> bit _too_ specific to the C language.
Good point. "RIGHT_function_hunk_header" doesn't really have much
meaning for non-programming language patterns like tex and html.
> I would prefer something like this
> instead:
>
> * a test case must have one (and only one) line that contains "RIGHT"
> (all uppercase) and that line should become the hunk header for the
> test to succeed.
>
> * after the line that contains "RIGHT" token, there should be one (and
> only one) line that contains "ChangeMe". The test modifies this
> token to "IWasChanged", compares the original with the modified
> result, and expects the "RIGHT" token above appears on the hunk
> header.
Both good improvements.
> Also I would prefer not to require "enough filler", as we might want to
> enhance the logic to consider using a line in the pre-context as the hunk
> header in some cases, e.g.
>
> @@ ... @@ int RIGHT_function_hunk_header(void)
>
> int RIGHT_function_hunk_header(void)
> {
> - int ChangeME;
> + int IWasChanged;
> printf("Hello, world\n");
> return 0;
> }
> @@ ...
Yeah, I didn't mean to imply that "enough filler" was a requirement of
the test, just trying to point out the requirement imposed by the hunk
header logic. I'll remove this statement.
Will reroll.
-Brandon
^ permalink raw reply
* Re: [PATCH] t4018: introduce test cases for the internal hunk header patterns
From: Junio C Hamano @ 2011-12-19 22:37 UTC (permalink / raw)
To: Brandon Casey; +Cc: peff, git, j6t, jrnieder, Brandon Casey
In-Reply-To: <31E9klcRboMV0wSJY5WO-N7nIBOUOa_wr6MVfWY9AInImxJIqC0flahvpDrVGMIuZ9e7Ouha1HDuesbwTGaNQA4dgN-FShNJKkfMG_cHLUJAT2rE539shnQxzM0dQyZIb5661As6Tvs@cipher.nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
> * new test cases can be dropped into the t4018 directory
> * filenames end with the pattern name e.g. .cpp .objc .matlab etc.
> * filenames should be descriptive since it will be used in the test
> suite output
> * broken test cases should be given a filename prefixed with "broken_"
Cute. I like the general idea.
> * test cases must provide a function named "RIGHT_function_hunk_header"
> - this is the function name that should appear on the hunk header line
> - the body of this function should have an assignment like
>
> answer = 0
>
> The test suite will modify the above line to produce a difference
> from the original. Additionally, this should be far enough within
> the body of the function so that the function name is not part of
> the lines of context.
Although I do not think of any language with a syntax rule where that the
overlong RIGHT_func... token is an illegal symbol offhand, this feels a
bit _too_ specific to the C language. I would prefer something like this
instead:
* a test case must have one (and only one) line that contains "RIGHT"
(all uppercase) and that line should become the hunk header for the
test to succeed.
* after the line that contains "RIGHT" token, there should be one (and
only one) line that contains "ChangeMe". The test modifies this
token to "IWasChanged", compares the original with the modified
result, and expects the "RIGHT" token above appears on the hunk
header.
Also I would prefer not to require "enough filler", as we might want to
enhance the logic to consider using a line in the pre-context as the hunk
header in some cases, e.g.
@@ ... @@ int RIGHT_function_hunk_header(void)
int RIGHT_function_hunk_header(void)
{
- int ChangeME;
+ int IWasChanged;
printf("Hello, world\n");
return 0;
}
@@ ...
^ permalink raw reply
* Re: How can I do an automatic stash when doing a checkout?
From: Junio C Hamano @ 2011-12-19 22:24 UTC (permalink / raw)
To: DeMarcus; +Cc: git
In-Reply-To: <jcobbo$jab$1@dough.gmane.org>
DeMarcus <demarcus@hotmail.com> writes:
> ... I don't really like to go back rearranging. I prefer to keep things
> spread out at first and then inserted properly when it's time. But maybe
> I'm just unused to the git workflow.
That does not have to do much with "the" git workflow.
If you are a kind of person who likes to work on N things concurrently
without ever making and recording mistakes but would rather keep
unfinished work without committing until done, you would need to have them
in your working trees. By definition you would need to use N working
trees, each of which permanently checks out its own branch, instead of a
single working tree where you checkout one of N branches at a time to work
on.
That is also a perfectly fine git workflow that we support with the
contributed script git-new-workdir.
^ permalink raw reply
* [PATCH] t4018: add a few more test cases for cpp hunk header matching
From: Brandon Casey @ 2011-12-19 21:53 UTC (permalink / raw)
To: peff; +Cc: git, j6t, gitster, jrnieder, trast, Brandon Casey
In-Reply-To: <31E9klcRboMV0wSJY5WO-N7nIBOUOa_wr6MVfWY9AInImxJIqC0flahvpDrVGMIuZ9e7Ouha1HDuesbwTGaNQA4dgN-FShNJKkfMG_cHLUJAT2rE539shnQxzM0dQyZIb5661As6Tvs@cipher.nrlssc.navy.mil>
From: Brandon Casey <drafnel@gmail.com>
Add one case for matching a function returning a pointer.
Plus add examples of things we explicitly do not match:
labels
function declarations
global variable declarations
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
This can be squashed into the original patch with the other test cases.
This just introduces a few more cases pointed out by Thomas Rast in the
email Johannes referenced.
http://thread.gmane.org/gmane.comp.version-control.git/186355/focus=186439
Also, note that all of the tests pass except for ignore_global.cpp with
Johannes's pattern:
"!^[ \\t]*[a-zA-Z_][a-zA-Z_0-9]*[^()]*:[[:space:]]*$\n^[a-zA-Z_][a-zA-Z_0-9]*.*"
-Brandon
t/t4018/ignore_declaration.cpp | 35 +++++++++++++++++++++++++++++++++++
t/t4018/ignore_global.cpp | 36 ++++++++++++++++++++++++++++++++++++
t/t4018/ignore_label.cpp | 35 +++++++++++++++++++++++++++++++++++
t/t4018/pointer_return.cpp | 34 ++++++++++++++++++++++++++++++++++
4 files changed, 140 insertions(+), 0 deletions(-)
create mode 100644 t/t4018/ignore_declaration.cpp
create mode 100644 t/t4018/ignore_global.cpp
create mode 100644 t/t4018/ignore_label.cpp
create mode 100644 t/t4018/pointer_return.cpp
diff --git a/t/t4018/ignore_declaration.cpp b/t/t4018/ignore_declaration.cpp
new file mode 100644
index 0000000..615aea0
--- /dev/null
+++ b/t/t4018/ignore_declaration.cpp
@@ -0,0 +1,35 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+ void WRONG_function_declaration_within_body (void);
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/ignore_global.cpp b/t/t4018/ignore_global.cpp
new file mode 100644
index 0000000..df6b8aa
--- /dev/null
+++ b/t/t4018/ignore_global.cpp
@@ -0,0 +1,36 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_global_variable;
+
+/*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+int answer = 0;
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/ignore_label.cpp b/t/t4018/ignore_label.cpp
new file mode 100644
index 0000000..2e3ce10
--- /dev/null
+++ b/t/t4018/ignore_label.cpp
@@ -0,0 +1,35 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+WRONG_should_not_match_label:
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/pointer_return.cpp b/t/t4018/pointer_return.cpp
new file mode 100644
index 0000000..fd85545
--- /dev/null
+++ b/t/t4018/pointer_return.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+static int *RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
--
1.7.7.4
^ permalink raw reply related
* Re: How can I do an automatic stash when doing a checkout?
From: DeMarcus @ 2011-12-19 21:46 UTC (permalink / raw)
To: git
In-Reply-To: <4EEF736A.4070802@ira.uka.de>
On 2011-12-19 18:24, Holger Hellmuth wrote:
> On 18.12.2011 16:10, DeMarcus wrote:
>>> You probably don't want to use stash. Just commit whatever partial work
>>> you've done.
>>>
>>
>> It feels strange doing a commit of partial work. Some of the files may
>> not even be supposed to be checked in.
>
> You have heard of "git commit --amend" ? Makes partial commits really
> easy to work with.
>
>
Yes, I know that one. It's just that I know myself, I don't really like
to go back rearranging. I prefer to keep things spread out at first and
then inserted properly when it's time. But maybe I'm just unused to the
git workflow.
^ permalink raw reply
* Re: How can I do an automatic stash when doing a checkout?
From: DeMarcus @ 2011-12-19 21:43 UTC (permalink / raw)
To: git
In-Reply-To: <4EEF63CA.4030201@dirk.my1.cc>
On 2011-12-19 17:18, Dirk Süsserott wrote:
> Am 18.12.2011 16:10 schrieb DeMarcus:
> [...]
>
>>>> With the git stash command I can clean the directory the way I want
>>>> but the stash command is not connected to a particular branch.
>>>>
>>>> Is there a way to have git checkout do an automatic stash when doing a
>>>> checkout to another branch, and then do an automatic git stash apply
>>>> with the correct stash when changing back to the previous branch
>>>> again?
>>>
>>> You probably don't want to use stash. Just commit whatever partial work
>>> you've done.
>>>
>>
>> It feels strange doing a commit of partial work. Some of the files may
>> not even be supposed to be checked in.
>>
>>> You could also just checkout different branches in different
>>> directories. Nothing wrong with doing that in git.
>>>
>>
>> Ok thanks, that would give me the same behavior as I have today.
>>
>> However, I can see some benefits with have everything in the same
>> directory as git allows compared to other VCSs. And since the stashing
>> feature is already there in git, it would be nice if the git checkout
>> with some flag could use stashing automatically.
>>
>>
>
> DeMarcus,
>
> probably a post-checkout hook could help you with autostashing, but that
> would need some scripting. Have a look at "git hooks --help".
> I sometimes use such a hook to auto-update submodules when checking out
> a branch. To be fair: I don't know how to identify the "right" stash then.
>
Thanks! I'll check that out. Maybe the right stash could be checked-in
itself somehow.
^ permalink raw reply
* Re: git-svn: multiple fetch lines
From: Nathan Gray @ 2011-12-19 21:40 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git, Eric Wong
In-Reply-To: <20111217100521.GA12610@elie.hsd1.il.comcast.net>
Hi,
On Sat, Dec 17, 2011 at 2:05 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:
> Hi Nathan,
>
> Nathan Gray wrote:
>
>> I'm in a conversation with the support fellow of the very nice Tower
>> git interface for OS X and we need clarification on a point. Does
>> git-svn explicitly support multiple "fetch =" lines in an svn-remote
>> section or is it just an accident that it works? My belief is that
>> such support is intended and his is that it is accidental.
>
> It's true that the documentation is not as clear about this as one
> might like. Documentation/git-svn.txt leaves it to the reader to
> infer that this is supported by analogy with "fetch =" lines in native
> git [remote] sections:
Thanks Jonathan, that's just what I suspected.
[snip]
> Perhaps such an example would be useful for the git-svn(1) manpage,
> too. Any ideas for where to add such a note, and how it should be
> worded? (Of course, if you can phrase such an idea in patch form,
> that would be the most convenient.)
The existing CONFIGURATION section of the man page seems like a
sensible place to mention multiple fetch entries. I've also found the
documentation on creating branches in the presence of multiple branch
keys to be confusing and in need of an example, so maybe that could go
in as well. How about something along these lines:
"""
In order to simplify working with messy subversion repositories you
can configure multiple fetch, branches, and tags keys. For example:
[svn-remote "messy-repo"]
url = http://server.org/svn
fetch = trunk/project-a:refs/remotes/project-a/trunk
fetch = branches/demos/june-project-a-demo:refs/remotes/project-a/demos/june-demo
branches = branches/server/*:refs/remotes/project-a/branches/*
branches = branches/demos/2011/*:refs/remotes/project-a/2011-demos/*
tags = tags/server/*:refs/remotes/project-a/tags/*
To create a branch in this configuration you need to specify the
location for the new branch using the -d or --destination flag. For
example:
git svn branch -d wtf-goes-here-anyway?? release-2-3-0
"""
The thing about the -d option that confuses me is that I'm not sure if
I'm supposed to be supplying a full svn path, a partial svn path, the
glob from the config file, etc. An example would make it obvious.
Personally, I always take the coward's way out and comment out the
extra branches keys, make the branch without -d, then restore them in
order to avoid any potential problems. :^)
Thanks,
-Nathan
--
HexaLex: A New Angle on Crossword Games for iPhone and iPod Touch
http://hexalex.com
On The App Store: http://bit.ly/8Mj1CU
On Facebook: http://bit.ly/9MIJiV
On Twitter: http://twitter.com/hexalexgame
http://n8gray.org
^ permalink raw reply
* Re: [PATCH] remote-curl: don't pass back fake refs
From: Jeff King @ 2011-12-19 21:29 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O. Pearce
In-Reply-To: <7v39cgmety.fsf@alter.siamese.dyndns.org>
On Mon, Dec 19, 2011 at 01:28:09PM -0800, Junio C Hamano wrote:
> > Do you want to squash in those tests, or should I re-send with a commit
> > message more fully explaining the situation?
>
> I was lazy and added these three lines at the end:
>
> This also fixes pushing with --mirror to a smart-http remote that uses
> alternates. The fake ".have" refs the server gives to avoid unnecessary
> network transfer has a similar bad interactions with the machinery.
>
> but it may warrant a more thorough write-up there.
I think that's probably enough. I could restructure the whole text to
talk less about capabilities^{} and more about generically preventing
fake refs, but I really don't think there's much point.
-Peff
^ permalink raw reply
* Re: [PATCH] remote-curl: don't pass back fake refs
From: Junio C Hamano @ 2011-12-19 21:28 UTC (permalink / raw)
To: Jeff King; +Cc: git, Shawn O. Pearce
In-Reply-To: <20111219211203.GA18396@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> On Mon, Dec 19, 2011 at 11:28:14AM -0800, Junio C Hamano wrote:
>
>> Jeff King <peff@peff.net> writes:
>>
>> > Perhaps we should squash in the test below, which demonstrates the
>> > breakage. I also wonder if this is maint-worthy.
>>
>> Thanks for a thorough analysis. I agree that this should go to maint even
>> more so, as it fixes a case to push to a non-empty repository.
>
> Do you want to squash in those tests, or should I re-send with a commit
> message more fully explaining the situation?
I was lazy and added these three lines at the end:
This also fixes pushing with --mirror to a smart-http remote that uses
alternates. The fake ".have" refs the server gives to avoid unnecessary
network transfer has a similar bad interactions with the machinery.
but it may warrant a more thorough write-up there.
^ permalink raw reply
* Re: [PATCH] remote-curl: don't pass back fake refs
From: Jeff King @ 2011-12-19 21:12 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Shawn O. Pearce
In-Reply-To: <7vty4wmkdt.fsf@alter.siamese.dyndns.org>
On Mon, Dec 19, 2011 at 11:28:14AM -0800, Junio C Hamano wrote:
> Jeff King <peff@peff.net> writes:
>
> > Perhaps we should squash in the test below, which demonstrates the
> > breakage. I also wonder if this is maint-worthy.
>
> Thanks for a thorough analysis. I agree that this should go to maint even
> more so, as it fixes a case to push to a non-empty repository.
Do you want to squash in those tests, or should I re-send with a commit
message more fully explaining the situation?
-Peff
^ permalink raw reply
* [PATCH] t4018: introduce test cases for the internal hunk header patterns
From: Brandon Casey @ 2011-12-19 20:52 UTC (permalink / raw)
To: peff; +Cc: git, j6t, gitster, jrnieder, Brandon Casey
In-Reply-To: <20111217012118.GB20225@sigill.intra.peff.net>
From: Brandon Casey <drafnel@gmail.com>
Recently it has been pointed out that one or more of the internal hunk
header patterns are sub-optimal. Specifically, the C/C++ "cpp" pattern was
called out.
Let's introduce some infrastructure to make it easy to create test cases
for the hunk header patterns and provide a few cases for the cpp pattern.
* new test cases can be dropped into the t4018 directory
* filenames end with the pattern name e.g. .cpp .objc .matlab etc.
* filenames should be descriptive since it will be used in the test
suite output
* broken test cases should be given a filename prefixed with "broken_"
* test cases must provide a function named "RIGHT_function_hunk_header"
- this is the function name that should appear on the hunk header line
- the body of this function should have an assignment like
answer = 0
The test suite will modify the above line to produce a difference
from the original. Additionally, this should be far enough within
the body of the function so that the function name is not part of
the lines of context.
Example test case:
int WRONG_function_hunk_header (void)
{
return 0;
}
int RIGHT_function_hunk_header (void)
{
/*
* Filler
* Filler
* Filler
*/
int answer = 0;
return 0;
}
Signed-off-by: Brandon Casey <drafnel@gmail.com>
---
On Fri, Dec 16, 2011 at 7:21 PM, Jeff King <peff@peff.net> wrote:
> On Fri, Dec 16, 2011 at 11:05:27PM +0100, Johannes Sixt wrote:
>
<snip>
>> ... in order to ultimately
>> improve the built-in pattern. The topic came up just the other day, and
>> I took Thomas Rast's suggestion to experiment with a simplified pattern:
>>
>> http://thread.gmane.org/gmane.comp.version-control.git/186355/focus=186439
>>
>> But as is, the built-in pattern misses way too many anchor points in C++
>> code.
>
> Yeah, I can certainly agree that the patterns could be better.
>
> Maybe we should just table the extension mapping for now, then, and see
> if the patterns improve? Or maybe just drop the C ones (and probably the
> objc one based on other parts of the thread) and do the rest?
/methinks t4018 needs to be greatly expanded. There is no way to tell what
is currently broken by the current pattern, or what is newly broken by a
new pattern.
How about this for a start?
-Brandon
t/t4018-diff-funcname.sh | 18 ++++++++++++
t/t4018/broken_class_constructor.cpp | 34 +++++++++++++++++++++++
t/t4018/broken_class_destructor.cpp | 34 +++++++++++++++++++++++
t/t4018/broken_gnu_style.cpp | 35 +++++++++++++++++++++++
t/t4018/broken_reference.cpp | 34 +++++++++++++++++++++++
t/t4018/broken_template.cpp | 34 +++++++++++++++++++++++
t/t4018/class_method.cpp | 34 +++++++++++++++++++++++
t/t4018/simple.cpp | 50 ++++++++++++++++++++++++++++++++++
t/t4018/static.cpp | 34 +++++++++++++++++++++++
9 files changed, 307 insertions(+), 0 deletions(-)
create mode 100644 t/t4018/broken_class_constructor.cpp
create mode 100644 t/t4018/broken_class_destructor.cpp
create mode 100644 t/t4018/broken_gnu_style.cpp
create mode 100644 t/t4018/broken_reference.cpp
create mode 100644 t/t4018/broken_template.cpp
create mode 100644 t/t4018/class_method.cpp
create mode 100644 t/t4018/simple.cpp
create mode 100644 t/t4018/static.cpp
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 4bd2a1c..5a1f7b7 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -121,6 +121,24 @@ do
! grep fatal msg &&
! grep error msg
'
+
+ for f in "$TEST_DIRECTORY"/t4018/*.$p; do
+ test -f "$f" || continue
+ name=`basename "$f" .$p`
+ test_expect_which=test_expect_success
+ if test "$name" != "${name#broken_}"; then
+ name=${name#broken_}
+ test_expect_which=test_expect_failure
+ fi
+ $test_expect_which \
+ "builtin $p pattern works correctly for $name case" "
+ echo \"*.$p diff=$p\" >.gitattributes &&
+ sed -e 's/answer = 0/answer = 42/' < \"$f\" > \"$name.$p\" &&
+ test_expect_code 1 git diff --no-index \"$f\" \
+ \"$name.$p\" >actual &&
+ egrep '^@@ .* @@ .*RIGHT_function_hunk_header' actual
+ "
+ done
done
test_expect_success 'default behaviour' '
diff --git a/t/t4018/broken_class_constructor.cpp b/t/t4018/broken_class_constructor.cpp
new file mode 100644
index 0000000..1e4cb9c
--- /dev/null
+++ b/t/t4018/broken_class_constructor.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+RIGHT_function_hunk_header::RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/broken_class_destructor.cpp b/t/t4018/broken_class_destructor.cpp
new file mode 100644
index 0000000..84d9506
--- /dev/null
+++ b/t/t4018/broken_class_destructor.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+RIGHT_function_hunk_header::~RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/broken_gnu_style.cpp b/t/t4018/broken_gnu_style.cpp
new file mode 100644
index 0000000..ffba9b9
--- /dev/null
+++ b/t/t4018/broken_gnu_style.cpp
@@ -0,0 +1,35 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int
+RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/broken_reference.cpp b/t/t4018/broken_reference.cpp
new file mode 100644
index 0000000..ea90b82
--- /dev/null
+++ b/t/t4018/broken_reference.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int& RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/broken_template.cpp b/t/t4018/broken_template.cpp
new file mode 100644
index 0000000..95a6dd5
--- /dev/null
+++ b/t/t4018/broken_template.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+template <class T> int RIGHT_function_hunk_header (T unused)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/class_method.cpp b/t/t4018/class_method.cpp
new file mode 100644
index 0000000..2e51853
--- /dev/null
+++ b/t/t4018/class_method.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int test_class::RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/simple.cpp b/t/t4018/simple.cpp
new file mode 100644
index 0000000..b8fca06
--- /dev/null
+++ b/t/t4018/simple.cpp
@@ -0,0 +1,50 @@
+/*
+ * Test file for testing the internal hunk header patterns
+ *
+ * The "RIGHT" hunk header function, the one that should appear on the
+ * hunk header line, should be named "RIGHT_function_hunk_header" and
+ * the body of this function should have an assignment that looks like
+ *
+ * answer = 0
+ *
+ * within it, deep enough so the lines of context do not include the
+ * function name.
+ *
+ * If the name of this file begins with "broken_", then it will be
+ * interpreted as a pattern which does not work, but which should.
+ */
+
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+int RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
diff --git a/t/t4018/static.cpp b/t/t4018/static.cpp
new file mode 100644
index 0000000..fcc48f2
--- /dev/null
+++ b/t/t4018/static.cpp
@@ -0,0 +1,34 @@
+int WRONG_function_hunk_header_preceding_the_right_one (void)
+{
+ return 0;
+}
+
+static int RIGHT_function_hunk_header (void)
+{
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ int answer = 0;
+
+ /*
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ * Filler
+ */
+
+ return answer;
+}
+
+int WRONG_function_hunk_header_following_the_right_one (void)
+{
+ return 0;
+}
--
1.7.7.4
^ permalink raw reply related
* Re: [PATCHv2 2/2] attr: drop C/C++ default extension mapping
From: Thomas Rast @ 2011-12-19 20:51 UTC (permalink / raw)
To: Jonathan Nieder
Cc: Jeff King, git, Johannes Sixt, Junio C Hamano, Brandon Casey,
Philip Oakley
In-Reply-To: <20111219181003.GB12200@elie.hsd1.il.comcast.net>
Jonathan Nieder <jrnieder@gmail.com> writes:
> Jeff King wrote:
>
>> But when you think about it, if our funcname pattern is bad, shouldn't
>> preventing (2) be the right thing? That is, if our funcname pattern is
>> really worse than the default language-agnostic match, wouldn't we be
>> doing everybody a service to simply remove the builtin
>> diff.cpp.xfuncname pattern?
>
> I don't see why. Anyone who has set "diff=cpp" either likes suffering
> (maybe they are hoping to improve the pattern) or is working with a
> codebase for which the current pattern works better than the default
> behavior (maybe their codebase has a lot of goto labels aligned at
> column zero). So removing the funcname pattern can only hurt them.
FWIW, the funcname pattern is not the only feature of the diff
attributes. I set it mainly to get the built-in --word-diff split
regexes.
I agree with Peff's patches though, until the cpp pattern improves, we
should not turn them on by default.
--
Thomas Rast
trast@{inf,student}.ethz.ch
^ permalink raw reply
* Re: [PATCH] lf_to_crlf_filter(): tell the caller we added "\n" when draining
From: Junio C Hamano @ 2011-12-19 20:23 UTC (permalink / raw)
To: Henrik Grubbström; +Cc: Git Mailing list, Carlos Martín Nieto
In-Reply-To: <Pine.GSO.4.63.1112191114010.4136@shipon.roxen.com>
Henrik Grubbström <grubba@roxen.com> writes:
> We probably ought to have a corresponding test in the testsuite.
> A blob consisting of a singe 'A' followed by 8192 linefeeds should
> be sufficient to trigger the problems.
Sounds good. Please make it so.
^ permalink raw reply
* Re: git 1.7.7.5
From: Junio C Hamano @ 2011-12-19 20:22 UTC (permalink / raw)
To: Thomas Jarosch; +Cc: Jonathan Nieder, git
In-Reply-To: <201112191041.07629.thomas.jarosch@intra2net.com>
Thomas Jarosch <thomas.jarosch@intra2net.com> writes:
> On Friday, 16. December 2011 11:57:58 Jonathan Nieder wrote:
>> I noticed that v1.7.7.5 was tagged a few days ago (b36dcd72), but
>> there is no corresponding tarball at
>>
>> http://code.google.com/p/git-core/downloads/list
>>
>> Will there be an official tarball?
>>
>> I don't mind either way, but it would be useful to know whether
>> distributors should make their own or just wait.
>
> Looks like a bug, the front page of "git-scm.com" also shows 1.7.7.5
> as latest stable release and leads to a dead link.
There actually is no bug; I just haven't got around to generating signed
tarballs yet.
I tend to agree that after 1.7.8 was released, showing 1.7.7.5 as the
latest stable indeed a bug (1.7.8 is still the latest stable and the next
latest stable will be 1.7.8.1), but that site is not under my direct
control, so...
^ permalink raw reply
* Re: [PATCH 2/2] push: hint to use push.default=upstream when appropriate
From: Junio C Hamano @ 2011-12-19 20:16 UTC (permalink / raw)
To: Jeff King; +Cc: git
In-Reply-To: <20111219103746.GB1736@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> It seems like the real problem is that they are on branch "foo", but the
> matching behavior tried to push "bar", which didn't work. And we are
> worried that they may be surprised that we even attempted to push "bar"
> at all.
Of we may be seeing a non-fast-forward on 'foo' itself, which is your
1. below.
> And that probably happened because of the situation you describe, but we
> (and the user) don't have to think about that. We can just think about
> the more immediate mistake of "oops, I didn't want to push 'bar'".
>
> Which leads me to two ideas:
>
> 1. This is not good advice to give when pushing the _current_ branch
> failed due to non-ff. Setting push.default to "upstream" would
> probably yield the same error. We should probably tighten the
> condition for showing this message to when a non-HEAD branch failed
> to fast-forward.
>
> 2. The text should focus on the (possible) local misconfiguration, not
> the repo setup.
OK, I think we are in agreement.
> So maybe something like:
>
> By default, git pushes all branches that have a matching counterpart
> on the remote. In this case, some of your local branches were stale
> with respect to their remote counterparts. If you did not intend to
> push these branches, you may want to set the 'push.default'
> configuration variable to 'upstream' to push only the current branch.
>
> I'm not 100% happy with that text, but I think you can see the direction
> I am talking about.
As long as we can tighten the condition further to ensure that the advice
above is triggered only when appropriate, I actually am 100% happy with
that text. Seeing others do the real work for me always makes me happy ;-)
In addition to "did we use default-matching?", we should use "did we get
non-fast-forward error on a branch that is _not_ the current one?" instead
of the "did we get any non-fast-forward error?" in my patch, and the text
should match the situation more-or-less exactly.
> ... If we follow my suggestion above and
> only print this message for non-HEAD refs, then these two messages
> become an either/or situation, I think. If the HEAD failed to
> fast-forward, then the right advice is probably "git pull && git push".
> If a non-HEAD failed, then the right advice is either "git checkout $X
> && git pull && git push" or "here's how to avoid accidentally pushing
> $X".
>
> So the logic would be something like:
>
> if (nonfastforward == NONFASTFORWARD_HEAD)
> advise_pull_before_push();
> else if (nonfastforward == NONFASTFORWAD_OTHER) {
> if (default_matching_used)
> advise_use_upstream();
> else
> advise_checkout_pull_push();
> }
Sounds good. Spelling things out at this detail would let others who may
be interested in getting their hands dirty try to come up with an updated
patch ;-).
Thanks.
^ permalink raw reply
* Re: Re* How to generate pull-request with info of signed tag
From: Junio C Hamano @ 2011-12-19 20:06 UTC (permalink / raw)
To: Git Mailing List; +Cc: Aneesh Kumar K.V
In-Reply-To: <7vobv4mj4r.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
> Come to think of it, the last patch I sent out on request pull was very
> wrong....
And this should fix it.
-- >8 --
Subject: [PATCH] request-pull: do not emit "tag" before the tagname
The whole point of the recent update to allow "git pull $url $tagname" is
so that the integrator does not have to store the (signed) tag that is
used to convey authenticity to be recorded in the resulting merge in the
local repository's tag namespace. Asking for a merge be made with "git
pull $url tag $tagname" defeats it.
Note that the request can become ambiguous if the requestor has a branch
with the same name as the tag, but that is not a new problem limited to
pulling. I wouldn't mind if somebody wants to add disambiguation to the
find_matching_ref logic in the script as a separate patch, though.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
git-request-pull.sh | 4 +---
t/t5150-request-pull.sh | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/git-request-pull.sh b/git-request-pull.sh
index 7b5c777..d7ba117 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -63,10 +63,8 @@ die "fatal: No commits in common between $base and $head"
find_matching_ref='
sub abbr {
my $ref = shift;
- if ($ref =~ s|refs/heads/||) {
+ if ($ref =~ s|refs/heads/|| || $ref =~ s|refs/tags/||) {
return $ref;
- } elsif ($ref =~ s|refs/tags/||) {
- return "tag $ref";
} else {
return $ref;
}
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index aec842f..da25bc2 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -180,7 +180,7 @@ test_expect_success 'request names an appropriate branch' '
read branch
} <digest &&
{
- test "$branch" = tag--full ||
+ test "$branch" = full ||
test "$branch" = master ||
test "$branch" = for-upstream
}
--
1.7.8.370.gb3269
^ permalink raw reply related
* Re: Re* How to generate pull-request with info of signed tag
From: Junio C Hamano @ 2011-12-19 19:55 UTC (permalink / raw)
To: Aneesh Kumar K.V; +Cc: Git Mailing List
In-Reply-To: <87iplch79e.fsf@linux.vnet.ibm.com>
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> writes:
> It would be nice to get the below working
>
> git fetch git-url tag remote-tag-name:local-namespace/tag-name
AFAIR "fetch tag $v" is a shorthand for "fetch refs/tags/$v:refs/tags/$"
invented back when Linus was the maintainer of Git. You can say
$ git fetch $url refs/tags/remote-tag-name:refs/tags/whatever-tag-name-you-want
to rename their tag to whatever name in your local repository.
Come to think of it, the last patch I sent out on request pull was very
wrong. The point of the recent change to allow you to pull this way
(notice the lack of "tag")
$ git pull $url $signed_tag_name
is so that you do not have to contaminate your own ref namespace with tags
that are used to leave audit trails in the history graph.
> That way we can make sure before merging i can cut-paste that url and
> the local tag name i wish to store this to. And then do a git-merge.
^ permalink raw reply
* Re: [PATCH] remote-curl: don't pass back fake refs
From: Junio C Hamano @ 2011-12-19 19:28 UTC (permalink / raw)
To: Jeff King; +Cc: git, Shawn O. Pearce, Junio C Hamano
In-Reply-To: <20111219171055.GA21227@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Perhaps we should squash in the test below, which demonstrates the
> breakage. I also wonder if this is maint-worthy.
Thanks for a thorough analysis. I agree that this should go to maint even
more so, as it fixes a case to push to a non-empty repository.
^ permalink raw reply
* Re: [PATCHv2 1/2] attr: map builtin userdiff drivers to well-known extensions
From: Jeff King @ 2011-12-19 18:55 UTC (permalink / raw)
To: Jonathan Nieder
Cc: git, Johannes Sixt, Junio C Hamano, Brandon Casey, Philip Oakley
In-Reply-To: <20111219180733.GA12200@elie.hsd1.il.comcast.net>
On Mon, Dec 19, 2011 at 12:07:33PM -0600, Jonathan Nieder wrote:
> > The C mappings are still here, but see the next patch.
>
> This is adding a regression in order to remove it. I guess it's
> harmless, but I don't see the point.
It's purely an attempt to help somebody reading "git log" later
understand what happened. Maybe a comment in the commit message is more
appropriate.
> > +test_expect_success 'binary files are not considered text by file extension' '
> > + echo Q | q_to_nul >binary.c &&
> > + git add binary.c &&
> > + cat >expect <<-\EOF &&
> > + diff --git a/binary.c b/binary.c
> > + new file mode 100644
> > + index 0000000..1f2a4f5
> > + Binary files /dev/null and b/binary.c differ
> > + EOF
> > + git diff --cached binary.c >actual &&
> > + test_cmp expect actual
>
> Re the idea of this test: very good idea.
>
> Re the mechanics: I would have been happier to see
>
> echo Q | q_to_nul >binary.c &&
> git add binary.c &&
> git diff --cached binary.c >diff &&
> grep Binary files diff
Yeah, I think that's fine, and I'll squash it in to my local version.
It does miss one problem, though (that is also present in my original):
using "binary.c" is no longer a good name, since the next patch will
revert the "*.c" bits. :)
> > --- a/t/t4018-diff-funcname.sh
> > +++ b/t/t4018-diff-funcname.sh
> > @@ -124,7 +124,9 @@ do
> > done
> >
> > test_expect_success 'default behaviour' '
> > - rm -f .gitattributes &&
> > + cat >.gitattributes <<-\EOF &&
> > + *.java diff=default
> > + EOF
> > test_expect_funcname "public class Beer\$"
> > '
>
> echo "*.java diff=default" >.gitattributes
>
> would do the same with two lines fewer. :)
Yup. I was following the style of the test directly below, which sets
both java and perl drivers. But the "default" test that needed updating
only checks the java case.
Will squash.
> Thanks for working on this. I owe you a beer.
You're welcome. :)
-Peff
^ permalink raw reply
* Re: [PATCHv2 2/2] attr: drop C/C++ default extension mapping
From: Jonathan Nieder @ 2011-12-19 18:10 UTC (permalink / raw)
To: Jeff King
Cc: git, Johannes Sixt, Junio C Hamano, Brandon Casey, Philip Oakley
In-Reply-To: <20111219155737.GB19829@sigill.intra.peff.net>
Jeff King wrote:
> But when you think about it, if our funcname pattern is bad, shouldn't
> preventing (2) be the right thing? That is, if our funcname pattern is
> really worse than the default language-agnostic match, wouldn't we be
> doing everybody a service to simply remove the builtin
> diff.cpp.xfuncname pattern?
I don't see why. Anyone who has set "diff=cpp" either likes suffering
(maybe they are hoping to improve the pattern) or is working with a
codebase for which the current pattern works better than the default
behavior (maybe their codebase has a lot of goto labels aligned at
column zero). So removing the funcname pattern can only hurt them.
^ permalink raw reply
* Re: [PATCHv2 1/2] attr: map builtin userdiff drivers to well-known extensions
From: Jonathan Nieder @ 2011-12-19 18:07 UTC (permalink / raw)
To: Jeff King
Cc: git, Johannes Sixt, Junio C Hamano, Brandon Casey, Philip Oakley
In-Reply-To: <20111219154938.GA19829@sigill.intra.peff.net>
Hi,
Two quick thoughts:
Jeff King wrote:
> The C mappings are still here, but see the next patch.
This is adding a regression in order to remove it. I guess it's
harmless, but I don't see the point.
[...]
> --- a/t/t4012-diff-binary.sh
> +++ b/t/t4012-diff-binary.sh
> @@ -90,4 +90,17 @@ test_expect_success 'diff --no-index with binary creation' '
> test_cmp expected actual
> '
>
> +test_expect_success 'binary files are not considered text by file extension' '
> + echo Q | q_to_nul >binary.c &&
> + git add binary.c &&
> + cat >expect <<-\EOF &&
> + diff --git a/binary.c b/binary.c
> + new file mode 100644
> + index 0000000..1f2a4f5
> + Binary files /dev/null and b/binary.c differ
> + EOF
> + git diff --cached binary.c >actual &&
> + test_cmp expect actual
Re the idea of this test: very good idea.
Re the mechanics: I would have been happier to see
echo Q | q_to_nul >binary.c &&
git add binary.c &&
git diff --cached binary.c >diff &&
grep Binary files diff
since that would avoid hard-coding some assumptions:
- the blob name of binary.c
- that [diff] mnemonicprefix defaults to false (I'd like to see the
default change to true)
- that [core] abbrev defaults to 7 (it probably won't change, but
it's a distracting detail, and if we were starting over 8 might be
a better default)
A bonus comment: :)
[...]
> --- a/t/t4018-diff-funcname.sh
> +++ b/t/t4018-diff-funcname.sh
> @@ -124,7 +124,9 @@ do
> done
>
> test_expect_success 'default behaviour' '
> - rm -f .gitattributes &&
> + cat >.gitattributes <<-\EOF &&
> + *.java diff=default
> + EOF
> test_expect_funcname "public class Beer\$"
> '
echo "*.java diff=default" >.gitattributes
would do the same with two lines fewer. :)
Thanks for working on this. I owe you a beer.
Jonathan
^ permalink raw reply
* Re: How can I do an automatic stash when doing a checkout?
From: Holger Hellmuth @ 2011-12-19 17:24 UTC (permalink / raw)
To: DeMarcus; +Cc: git
In-Reply-To: <jckvpk$i8v$1@dough.gmane.org>
On 18.12.2011 16:10, DeMarcus wrote:
>> You probably don't want to use stash. Just commit whatever partial work
>> you've done.
>>
>
> It feels strange doing a commit of partial work. Some of the files may
> not even be supposed to be checked in.
You have heard of "git commit --amend" ? Makes partial commits really
easy to work with.
^ permalink raw reply
* Re: Pushing with --mirror over HTTP?
From: Jeff King @ 2011-12-19 17:12 UTC (permalink / raw)
To: Eli Barzilay; +Cc: git
In-Reply-To: <20072.12104.965815.994761@winooski.ccs.neu.edu>
On Wed, Sep 07, 2011 at 10:58:16PM -0400, Eli Barzilay wrote:
> 5 hours ago, Jeff King wrote:
> > On Mon, Sep 05, 2011 at 12:05:37AM -0400, Eli Barzilay wrote:
> >
> > > Is there anything broken with pushing with mirror over HTTP? I'm
> > > trying that with a github url, and I get a broken-looking error
> > > message:
> > >
> > > remote part of refspec is not a valid name in :.have
> >
> > It's probably nothing to do with http, but rather with alternate
> > object databases on the server (which GitHub uses heavily). The
> > server hands out fake ".have" refs telling you it has some other
> > branch tips to base packs off of. So I suspect the "push --mirror"
> > code is simply wrong for trying to update those refs (it may be
> > exacerbated by using http, though, as the remote helper code seems
> > to have some extra checks).
Sorry for the very delayed response on your bug, but at least I have
good news. :)
It should be fixed by:
http://article.gmane.org/gmane.comp.version-control.git/187373
(I was trying to fix another bug there, but see my followup for a
discussion of .have).
-Peff
^ permalink raw reply
* Re: [PATCH] remote-curl: don't pass back fake refs
From: Jeff King @ 2011-12-19 17:10 UTC (permalink / raw)
To: git; +Cc: Shawn O. Pearce, Junio C Hamano
In-Reply-To: <20111217104539.GA23844@sigill.intra.peff.net>
On Sat, Dec 17, 2011 at 05:45:39AM -0500, Jeff King wrote:
> Most of the time this bug goes unnoticed, as the fake ref
> won't match our refspecs. However, if "--mirror" is used,
> then we see it as remote cruft to be pruned, and try to pass
> along a deletion refspec for it. Of course this refspec has
> bogus syntax (because of the ^{}), and the helper complains,
> aborting the push.
>
> Let's have remote-curl mirror what the builtin
> get_refs_via_connect does (at least for the case of using
> git protocol; we can leave the dumb info/refs reader as it
> is).
I did some experimenting, and this also fixes another bug: pushing with
--mirror to a smart-http remote that uses alternates.
The fake ".have" refs that the server produces are similarly bogus and
should not be passed back from remote-curl to the parent git process.
Currently they are, so you get:
remote part of refspec is not a valid name in :.have
in the --mirror case.
I had thought this patch wouldn't make a difference there, since
get_remote_heads handles ".have" specifically before the check_refname
call. But it only does so if you pass in a non-NULL extra_have_objects
pointer. We do for regular git (since we care about the .haves for
efficiency, obviously).
But for smart-http, we actually end up parsing the refs twice: once to
get the list of refs to hand back to the parent git process, and then
again later in a send-pack subprocess that actually does care about the
.haves. In the first one, we just pass NULL for extra_have, and
get_remote_heads happily adds the bogus ones to the list.
For the same reason that this patch squelches the bogus "capability^{}",
it also squelches the bogus ".have" refs (but of course they are still
in our buffer to be handed to send-pack, so there is no loss of
efficiency).
Perhaps we should squash in the test below, which demonstrates the
breakage. I also wonder if this is maint-worthy.
-Peff
---
diff --git a/t/t5541-http-push.sh b/t/t5541-http-push.sh
index 89232b2..9b85d42 100755
--- a/t/t5541-http-push.sh
+++ b/t/t5541-http-push.sh
@@ -168,5 +168,23 @@ test_expect_success 'push --mirror can push to empty repo' '
git push --mirror "$HTTPD_URL"/smart/empty-mirror.git
'
+test_expect_success 'push --all to repo with alternates' '
+ s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
+ d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-all.git &&
+ git clone --bare --shared "$s" "$d" &&
+ git --git-dir="$d" config http.receivepack true &&
+ git --git-dir="$d" repack -adl &&
+ git push --all "$HTTPD_URL"/smart/alternates-all.git
+'
+
+test_expect_success 'push --mirror to repo with alternates' '
+ s=$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git &&
+ d=$HTTPD_DOCUMENT_ROOT_PATH/alternates-mirror.git &&
+ git clone --bare --shared "$s" "$d" &&
+ git --git-dir="$d" config http.receivepack true &&
+ git --git-dir="$d" repack -adl &&
+ git push --mirror "$HTTPD_URL"/smart/alternates-mirror.git
+'
+
stop_httpd
test_done
^ 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