gitweb.git
merge-recursive: Consolidate process_entry() and proces... Elijah Newren Fri, 12 Aug 2011 05:20:07 +0000 (23:20 -0600)

merge-recursive: Consolidate process_entry() and process_df_entry()

The whole point of adding process_df_entry() was to ensure that files of
D/F conflicts were processed after paths under the corresponding
directory. However, given that the entries are in sorted order, all we
need to do is iterate through them in reverse order to achieve the same
effect. That lets us remove some duplicated code, and lets us keep
track of one less thing as we read the code ("do we need to make sure
this is processed before process_df_entry() or do we need to defer it
until then?").

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Improve handling of rename target... Elijah Newren Fri, 12 Aug 2011 05:20:06 +0000 (23:20 -0600)

merge-recursive: Improve handling of rename target vs. directory addition

When dealing with file merging and renames and D/F conflicts and possible
criss-cross merges (how's that for a corner case?), we did not do a
thorough job ensuring the index and working directory had the correct
contents. Fix the logic in merge_content() to handle this. Also,
correct some erroneous tests in t6022 that were expecting the wrong number
of unmerged index entries. These changes fix one of the tests in t6042
(and almost fix another one from t6042 as well).

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Add comments about handling rename... Elijah Newren Fri, 12 Aug 2011 05:20:05 +0000 (23:20 -0600)

merge-recursive: Add comments about handling rename/add-source cases

There are a couple of places where changes are needed to for situations
involving rename/add-source issues. Add comments about the needed changes
(and existing bugs) until git has been enabled to detect such cases.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Make dead code for rename/rename(2to1... Elijah Newren Fri, 12 Aug 2011 05:20:04 +0000 (23:20 -0600)

merge-recursive: Make dead code for rename/rename(2to1) conflicts undead

The code for rename_rename_2to1 conflicts (two files both being renamed to
the same filename) was dead since the rename/add path was always being
independently triggered for each of the renames instead. Further,
reviving the dead code showed that it was inherently buggy and would
always segfault -- among a few other bugs.

Move the else-if branch for the rename/rename block before the rename/add
block to make sure it is checked first, and fix up the rename/rename(2to1)
code segments to make it handle most cases. Work is still needed to
handle higher dimensional corner cases such as rename/rename/modify/modify
issues.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Fix deletion of untracked file in... Elijah Newren Fri, 12 Aug 2011 05:20:03 +0000 (23:20 -0600)

merge-recursive: Fix deletion of untracked file in rename/delete conflicts

In the recursive case (o->call_depth > 0), we do not modify the working
directory. However, when o->call_depth==0, file renames can mean we need
to delete the old filename from the working copy. Since there have been
lots of changes and mistakes here, let's go through the details. Let's
start with a simple explanation of what we are trying to achieve:

Original goal: If a file is renamed on the side of history being merged
into head, the filename serving as the source of that rename needs to be
removed from the working directory.

The path to getting the above statement implemented in merge-recursive took
several steps. The relevant bits of code may be instructive to keep in
mind for the explanation, especially since an English-only description
involves double negatives that are hard to follow. These bits of code are:
int remove_file(..., const char *path, int no_wd)
{
...
int update_working_directory = !o->call_depth && !no_wd;
and
remove_file(o, 1, ren1_src, <expression>);
Where the choice for <expression> has morphed over time:

65ac6e9 (merge-recursive: adjust to loosened "working file clobbered"
check 2006-10-27), introduced the "no_wd" parameter to remove_file() and
used "1" for <expression>. This meant ren1_src was never deleted, leaving
it around in the working copy.

In 8371234 (Remove uncontested renamed files during merge. 2006-12-13),
<expression> was changed to "index_only" (where index_only ==
!!o->call_depth; see b7fa51da). This was equivalent to using "0" for
<expression> (due to the early logic in remove_file), and is orthogonal to
the condition we actually want to check at this point; it resulted in the
source file being removed except when index_only was false. This was
problematic because the file could have been renamed on the side of history
including head, in which case ren1_src could correspond to an untracked
file that should not be deleted.

In 183d797 (Keep untracked files not involved in a merge. 2007-02-04),
<expression> was changed to "index_only || stage == 3". While this gives
correct behavior, the "index_only ||" portion of <expression> is
unnecessary and makes the code slightly harder to follow.

There were also two further changes to this expression, though without
any change in behavior. First in b7fa51d (merge-recursive: get rid of the
index_only global variable 2008-09-02), it was changed to "o->call_depth
|| stage == 3". (index_only == !!o->call_depth). Later, in 41d70bd6
(merge-recursive: Small code clarification -- variable name and comments),
this was changed to "o->call_depth || renamed_stage == 2" (where stage was
renamed to other_stage and renamed_stage == other_stage ^ 1).

So we ended with <expression> being "o->call_depth || renamed_stage == 2".
But the "o->call_depth ||" piece was unnecessary. We can remove it,
leaving us with <expression> being "renamed_stage == 2". This doesn't
change behavior at all, but it makes the code clearer. Which is good,
because it's about to get uglier.

Corrected goal: If a file is renamed on the side of history being merged
into head, the filename serving as the source of that rename needs to be
removed from the working directory *IF* that file is tracked in head AND
the file tracked in head is related to the original file.

Note that the only difference between the original goal and the corrected
goal is the two extra conditions added at the end. The first condition is
relevant in a rename/delete conflict. If the file was deleted on the
HEAD side of the merge and an untracked file of the same name was added to
the working copy, then without that extra condition the untracked file
will be erroneously deleted. This changes <expression> to "renamed_stage
== 2 || !was_tracked(ren1_src)".

The second additional condition is relevant in two cases.

The first case the second condition can occur is when a file is deleted
and a completely different file is added with the same name. To my
knowledge, merge-recursive has no mechanism for detecting deleted-and-
replaced-by-different-file cases, so I am simply punting on this
possibility.

The second case for the second condition to occur is when there is a
rename/rename/add-source conflict. That is, when the original file was
renamed on both sides of history AND the original filename is being
re-used by some unrelated (but tracked) content. This case also presents
some additional difficulties for us since we cannot currently detect these
rename/rename/add-source conflicts; as long as the rename detection logic
"optimizes" by ignoring filenames that are present at both ends of the
diff, these conflicts will go unnoticed. However, rename/rename conflicts
are handled by an entirely separate codepath not being discussed here, so
this case is not relevant for the line of code under consideration.

In summary:
Change <expression> from "o->call_depth || renamed_stage == 2" to
"renamed_stage == 2 || !was_tracked(ren1_src)", in order to remove
unnecessary code and avoid deleting untracked files.

96 lines of explanation in the changelog to describe a one-line fix...

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Split update_stages_and_entry; only... Elijah Newren Fri, 12 Aug 2011 05:20:02 +0000 (23:20 -0600)

merge-recursive: Split update_stages_and_entry; only update stages at end

Instead of having the process_renames logic update the stages in the index
for the rename destination, have the index updated after process_entry or
process_df_entry. This will also allow us to have process_entry determine
whether a file was tracked and existed in the working copy before the
merge started.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Allow make_room_for_path() to remove... Elijah Newren Fri, 12 Aug 2011 05:20:01 +0000 (23:20 -0600)

merge-recursive: Allow make_room_for_path() to remove D/F entries

If there were several files conflicting below a directory corresponding
to a D/F conflict, and the file of that D/F conflict is in the way, we
want it to be removed. Since files of D/F conflicts are handled last,
they can be reinstated later and possibly with a new unique name.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

string-list: Add API to remove an item from an unsorted... Johannes Sixt Fri, 12 Aug 2011 05:20:00 +0000 (23:20 -0600)

string-list: Add API to remove an item from an unsorted list

Teach the string-list API how to remove an entry in O(1) runtime by
moving the last entry to the vacated spot. As such, the routine works
only for unsorted lists.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Split was_tracked() out of would_lose_... Elijah Newren Fri, 12 Aug 2011 05:19:59 +0000 (23:19 -0600)

merge-recursive: Split was_tracked() out of would_lose_untracked()

Checking whether a filename was part of stage 0 or stage 2 is code that we
would like to be able to call from a few other places without also
lstat()-ing the file to see if it exists in the working copy.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Save D/F conflict filenames instead... Elijah Newren Fri, 12 Aug 2011 05:19:58 +0000 (23:19 -0600)

merge-recursive: Save D/F conflict filenames instead of unlinking them

Rename make_room_for_directories_of_df_conflicts() to
record_df_conflict_files() to reflect the change in functionality.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Fix code checking for D/F conflicts... Elijah Newren Fri, 12 Aug 2011 05:19:57 +0000 (23:19 -0600)

merge-recursive: Fix code checking for D/F conflicts still being present

Previously, we were using lstat() to determine if a directory was still
present after a merge (and thus in the way of adding a file). We should
have been using lstat() only to determine if untracked directories were in
the way (and then only when necessary to check for untracked directories);
we should instead using the index to determine if there is a tracked
directory in the way. Create a new function to do this and use it to
replace the existing checks for directories being in the way.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Fix sorting order and directory change... Elijah Newren Fri, 12 Aug 2011 05:19:56 +0000 (23:19 -0600)

merge-recursive: Fix sorting order and directory change assumptions

We cannot assume that directory/file conflicts will appear in sorted
order; for example, 'letters.txt' comes between 'letters' and
'letters/file'.

Thanks to Johannes for a pointer about qsort stability issues with
Windows and suggested code change.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Fix recursive case with D/F conflict... Elijah Newren Fri, 12 Aug 2011 05:19:55 +0000 (23:19 -0600)

merge-recursive: Fix recursive case with D/F conflict via add/add conflict

When a D/F conflict is introduced via an add/add conflict, when
o->call_depth > 0 we need to ensure that the higher stage entry from the
base stage is removed.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Avoid working directory changes during... Elijah Newren Fri, 12 Aug 2011 05:19:54 +0000 (23:19 -0600)

merge-recursive: Avoid working directory changes during recursive case

make_room_for_directories_of_df_conflicts() is about making sure necessary
working directory changes can succeed. When o->call_depth > 0 (i.e. the
recursive case), we do not want to make any working directory changes so
this function should be skipped.

Note that make_room_for_directories_of_df_conflicts() is broken as has
been pointed out by Junio; it should NOT be unlinking files. What it
should do is keep track of files that could be unlinked if a directory
later needs to be written in their place. However, that work also is only
relevant in the non-recursive case, so this change is helpful either way.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Remember to free generated unique... Elijah Newren Fri, 12 Aug 2011 05:19:53 +0000 (23:19 -0600)

merge-recursive: Remember to free generated unique path names

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Consolidate different update_stages... Elijah Newren Fri, 12 Aug 2011 05:19:52 +0000 (23:19 -0600)

merge-recursive: Consolidate different update_stages functions

We are only calling update_stages_options() one way really, so we can
consolidate the slightly different variants into one and remove some
parameters whose values are always the same.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Mark some diff_filespec struct argumen... Elijah Newren Fri, 12 Aug 2011 05:19:51 +0000 (23:19 -0600)

merge-recursive: Mark some diff_filespec struct arguments const

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Correct a commentElijah Newren Fri, 12 Aug 2011 05:19:50 +0000 (23:19 -0600)

merge-recursive: Correct a comment

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

merge-recursive: Make BUG message more legible by addin... Elijah Newren Fri, 12 Aug 2011 05:19:49 +0000 (23:19 -0600)

merge-recursive: Make BUG message more legible by adding a newline

Hopefully no one ever hits this error except when making large changes to
merge-recursive.c and debugging...

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6022: Add testcase for merging a renamed file with... Elijah Newren Fri, 12 Aug 2011 05:19:48 +0000 (23:19 -0600)

t6022: Add testcase for merging a renamed file with a simple change

This is a testcase that was broken by b2c8c0a (merge-recursive: When we
detect we can skip an update, actually skip it 2011-02-28) and fixed by
6db4105 (Revert "Merge branch 'en/merge-recursive'" 2011-05-19). Include
this testcase to ensure we don't regress it again.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6022: New tests checking for unnecessary updates of... Elijah Newren Fri, 12 Aug 2011 05:19:47 +0000 (23:19 -0600)

t6022: New tests checking for unnecessary updates of files

This testcase was part of en/merge-recursive that was reverted in 6db4105
(Revert "Merge branch 'en/merge-recursive'" 2011-05-19). While the other
changes in that series caused unfortunate breakage, this testcase is still
useful; reinstate it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6022: Remove unnecessary untracked files to make test... Elijah Newren Fri, 12 Aug 2011 05:19:46 +0000 (23:19 -0600)

t6022: Remove unnecessary untracked files to make test cleaner

Since this test later does a git add -A, we should clean out unnecessary
untracked files as part of our cleanup.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036: criss-cross + rename/rename(1to2)/add-source... Elijah Newren Fri, 12 Aug 2011 05:19:45 +0000 (23:19 -0600)

t6036: criss-cross + rename/rename(1to2)/add-source + modify/modify

This is another challenging testcase trying to exercise the virtual merge
base creation in the rename/rename(1to2) code. A testcase is added that
we should be able to merge cleanly, but which requires a virtual merge
base to be created that is aware of rename/rename(1to2)/add-source
conflicts and can handle those.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036: criss-cross w/ rename/rename(1to2)/modify+rename... Elijah Newren Fri, 12 Aug 2011 05:19:44 +0000 (23:19 -0600)

t6036: criss-cross w/ rename/rename(1to2)/modify+rename/rename(2to1)/modify

This test is mostly just designed for testing optimality of the virtual
merge base in the event of a rename/rename(1to2) conflict. The current
choice for resolving this in git seems somewhat confusing and suboptimal.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036: tests for criss-cross merges with various direct... Elijah Newren Fri, 12 Aug 2011 05:19:43 +0000 (23:19 -0600)

t6036: tests for criss-cross merges with various directory/file conflicts

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036: criss-cross with weird content can fool git... Elijah Newren Fri, 12 Aug 2011 05:19:42 +0000 (23:19 -0600)

t6036: criss-cross with weird content can fool git into clean merge

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6036: Add differently resolved modify/delete conflict... Elijah Newren Fri, 12 Aug 2011 05:19:41 +0000 (23:19 -0600)

t6036: Add differently resolved modify/delete conflict in criss-cross test

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add failing testcases for rename/rename/add... Elijah Newren Fri, 12 Aug 2011 05:19:40 +0000 (23:19 -0600)

t6042: Add failing testcases for rename/rename/add-{source,dest} conflicts

Add testcases that cover three failures with current git merge, all
involving renaming one file on both sides of history:

Case 1:
If a single file is renamed to two different filenames on different sides
of history, there should be a conflict. Adding a new file on one of those
sides of history whose name happens to match the rename source should not
cause the merge to suddenly succeed.

Case 2:
If a single file is renamed on both sides of history but renamed
identically, there should not be a conflict. This works fine. However,
if one of those sides also added a new file that happened to match the
rename source, then that file should be left alone. Currently, the
rename/rename conflict handling causes that new file to become untracked.

Case 3:
If a single file is renamed to two different filenames on different sides
of history, there should be a conflict. This works currently. However,
if those renames also involve rename/add conflicts (i.e. there are new
files on one side of history that match the destination of the rename of
the other side of history), then the resulting conflict should be recorded
in the index, showing that there were multiple files with a given filename.
Currently, git silently discards one of file versions.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Ensure rename/rename conflicts leave index and... Elijah Newren Fri, 12 Aug 2011 05:19:39 +0000 (23:19 -0600)

t6042: Ensure rename/rename conflicts leave index and workdir in sane state

rename/rename conflicts, both with one file being renamed to two different
files and with two files being renamed to the same file, should leave the
index and the working copy in a sane state with appropriate conflict
recording, auxiliary files, etc. Git seems to handle one of the two cases
alright, but has some problems with the two files being renamed to one
case. Add tests for both cases.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add tests for content issues with modify/rename... Elijah Newren Fri, 12 Aug 2011 05:19:38 +0000 (23:19 -0600)

t6042: Add tests for content issues with modify/rename/directory conflicts

Add testcases that cover a variety of merge issues with files being
renamed and modified on different sides of history, when there are
directories possibly conflicting with the rename location.

Case 1:
On one side of history, a file is modified and a new directory is added.
On the other side of history, the file is modified in a non-conflicting
way but is renamed to the location of the new directory.

Case 2:
[Same as case 1, but there is also a content conflict. In detail:]
On one side of history, a file is modified and a new directory is added.
On the other side of history, the file is modified in a conflicting way
and it is renamed to the location of the new directory.

Case 3:
[Similar to case 1, but the "conflicting" directory is the directory
where the file original resided. In detail:]
On one side of history, a file is modified. On the other side of history,
the file is modified in a non-conflicting way, but the directory it was
under is removed and the file is renamed to the location of the directory
it used to reside in (i.e. 'sub/file' gets renamed to 'sub'). This is
flagged as a directory/rename conflict, but should be able to be resolved
since the directory can be cleanly removed by the merge.

One branch renames a file and makes a file where the directory the renamed
file used to be in, and the other branch updates the file in
place. Merging them should resolve it cleanly as long as the content level
change on the branches do not overlap and rename is detected, or should
leave conflict without losing information.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add a testcase where undetected rename causes... Elijah Newren Fri, 12 Aug 2011 05:19:37 +0000 (23:19 -0600)

t6042: Add a testcase where undetected rename causes silent file deletion

There are cases where history should merge cleanly, and which current git
does merge cleanly despite not detecting a rename; however the merge
currently nukes files that should not be removed.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add a pair of cases where undetected renames... Elijah Newren Fri, 12 Aug 2011 05:19:36 +0000 (23:19 -0600)

t6042: Add a pair of cases where undetected renames cause issues

An undetected rename can cause a silent success where a conflict should
have been detected, or can cause an erroneous conflict state where the
merge should have been resolvable. Add testcases for both.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add failing testcase for rename/modify/add-sourc... Elijah Newren Fri, 12 Aug 2011 05:19:35 +0000 (23:19 -0600)

t6042: Add failing testcase for rename/modify/add-source conflict

If there is a cleanly resolvable rename/modify conflict AND there is a new
file introduced on the renamed side of the merge whose name happens to
match that of the source of the rename (but is otherwise unrelated to the
rename), then git fails to cleanly resolve the merge despite the fact that
the new file should not cause any problems.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

t6042: Add a testcase where git deletes an untracked... Elijah Newren Fri, 12 Aug 2011 05:19:34 +0000 (23:19 -0600)

t6042: Add a testcase where git deletes an untracked file

Current git will nuke an untracked file during a rename/delete conflict if
(a) there is an untracked file whose name matches the source of a rename
and (b) the merge is done in a certain direction. Add a simple testcase
demonstrating this bug.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

ls-files: fix pathspec display on errorClemens Buchacher Mon, 1 Aug 2011 21:19:58 +0000 (23:19 +0200)

ls-files: fix pathspec display on error

The following sequence of commands reveals an issue with error
reporting of relative paths:

$ mkdir sub
$ cd sub
$ git ls-files --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.
$ git commit --error-unmatch ../bbbbb
error: pathspec 'b' did not match any file(s) known to git.

This bug is visible only if the normalized path (i.e., the relative
path from the repository root) is longer than the prefix.
Otherwise, the code skips over the normalized path and reads from
an unused memory location which still contains a leftover of the
original command line argument.

So instead, use the existing facilities to deal with relative paths
correctly.

Also fix inconsistency between "checkout" and "commit", e.g.

$ cd Documentation
$ git checkout nosuch.txt
error: pathspec 'Documentation/nosuch.txt' did not match...
$ git commit nosuch.txt
error: pathspec 'nosuch.txt' did not match...

by propagating the prefix down the codepath that reports the error.

Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

describe: Refresh the index when run with --dirtyAllan Caffee Mon, 1 Aug 2011 01:52:41 +0000 (21:52 -0400)

describe: Refresh the index when run with --dirty

When running git describe --dirty the index should be refreshed. Previously
the cached index would cause describe to think that the index was dirty when,
in reality, it was just stale.

The issue was exposed by python setuptools which hardlinks files into another
directory when building a distribution.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: consolidate definition of $LFJunio C Hamano Mon, 8 Aug 2011 18:51:00 +0000 (11:51 -0700)

test: consolidate definition of $LF

As we seem to need this variable that holds a single LF character
in many places, define it in test-lib.sh and let the test scripts
use it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tolerate zlib deflation with window size < 32KbRoberto Tyley Sun, 7 Aug 2011 18:46:13 +0000 (19:46 +0100)

Tolerate zlib deflation with window size < 32Kb

Git currently reports loose objects as 'corrupt' if they've been
deflated using a window size less than 32Kb, because the
experimental_loose_object() function doesn't recognise the header
byte as a zlib header. This patch makes the function tolerant of
all valid window sizes (15-bit to 8-bit) - but doesn't sacrifice
it's accuracy in distingushing the standard loose-object format
from the experimental (now abandoned) format.

On memory constrained systems zlib may use a much smaller window
size - working on Agit, I found that Android uses a 4KB window;
giving a header byte of 0x48, not 0x78. Consequently all loose
objects generated appear 'corrupt', which is why Agit is a read-only
Git client at this time - I don't want my client to generate Git
repos that other clients treat as broken :(

This patch makes Git tolerant of different deflate settings - it
might appear that it changes experimental_loose_object() to the point
where it could incorrectly identify the experimental format as the
standard one, but the two criteria (bitmask & checksum) can only
give a false result for an experimental object where both of the
following are true:

1) object size is exactly 8 bytes when uncompressed (bitmask)
2) [single-byte in-pack git type&size header] * 256
+ [1st byte of the following zlib header] % 31 = 0 (checksum)

As it happens, for all possible combinations of valid object type
(1-4) and window bits (0-7), the only time when the checksum will be
divisible by 31 is for 0x1838 - ie object type *1*, a Commit - which,
due the fields all Commit objects must contain, could never be as
small as 8 bytes in size.

Given this, the combination of the two criteria (bitmask & checksum)
always correctly determines the buffer format, and is more tolerant
than the previous version.

The alternative to this patch is simply removing support for the
experimental format, which I am also totally cool with.

References:

Android uses a 4KB window for deflation:
http://android.git.kernel.org/?p=platform/libcore.git;a=blob;f=luni/src/main/native/java_util_zip_Deflater.cpp;h=c0b2feff196e63a7b85d97cf9ae5bb2583409c28;hb=refs/heads/gingerbread#l53

Code snippet searching for false positives with the zlib checksum:
https://gist.github.com/1118177

Signed-off-by: Roberto Tyley <roberto.tyley@guardian.co.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

am: ignore leading whitespace before patchDavid Barr Mon, 8 Aug 2011 02:49:04 +0000 (04:49 +0200)

am: ignore leading whitespace before patch

Some web-based email clients prepend whitespace to raw message
transcripts to workaround content-sniffing in some browsers. Adjust
the patch format detection logic to ignore leading whitespace.

So now you can apply patches from GMail with "git am" in three steps:

1. choose "show original"
2. tell the browser to "save as" (for example by pressing Ctrl+S)
3. run "git am" on the saved file

This fixes a regression introduced by v1.6.4-rc0~15^2~2 (git-am
foreign patch support: autodetect some patch formats, 2009-05-27).
GMail support was first introduced to "git am" by v1.5.4-rc0~274^2
(Make mailsplit and mailinfo strip whitespace from the start of the
input, 2007-11-01).

Signed-off-by: David Barr <davidbarr@google.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

add update 'none' flag to disable update of submodule... Heiko Voigt Thu, 11 Aug 2011 17:51:46 +0000 (19:51 +0200)

add update 'none' flag to disable update of submodule by default

This is useful to mark a submodule as unneeded by default. When this
option is set and the user wants to work with such a submodule he
needs to configure 'submodule.<name>.update=checkout' or pass the
--checkout option. Then the submodule can be handled like a normal
submodule.

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: move update configuration variable further upHeiko Voigt Thu, 11 Aug 2011 17:51:45 +0000 (19:51 +0200)

submodule: move update configuration variable further up

Lets always initialize the 'update_module' variable with the final
value. This way we allow code which wants to check this configuration
early to do so right in the beginning of cmd_update().

Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fsck: improve committer/author checkDmitry Ivankov Thu, 11 Aug 2011 10:21:10 +0000 (16:21 +0600)

fsck: improve committer/author check

fsck allows a name with > character in it like "name> <email>". Also for
"name email>" fsck says "missing space before email".

More precisely, it seeks for a first '<', checks that ' ' preceeds it.
Then seeks to '<' or '>' and checks that it is the '>'. Missing space is
reported if either '<' is not found or it's not preceeded with ' '.

Change it to following. Seek to '<' or '>', check that it is '<' and is
preceeded with ' '. Seek to '<' or '>' and check that it is '>'. So now
"name> <email>" is rejected as "bad name". More strict name check is the
only change in what is accepted.

Report 'missing space' only if '<' is found and is not preceeded with a
space.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fsck: add a few committer name testsDmitry Ivankov Thu, 11 Aug 2011 10:21:09 +0000 (16:21 +0600)

fsck: add a few committer name tests

fsck reports "missing space before <email>" for committer string equal
to "name email>" or to "". It'd be nicer to say "missing email" for
the second string and "name is bad" (has > in it) for the first one.
Add a failing test for these messages.

For "name> <email>" no error is reported. Looks like a bug, so add
such a failing test."

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: check committer name more strictlyDmitry Ivankov Thu, 11 Aug 2011 10:21:08 +0000 (16:21 +0600)

fast-import: check committer name more strictly

The documentation declares following identity format:
(<name> SP)? LT <email> GT
where name is any string without LF and LT characters.
But fast-import just accepts any string up to first GT
instead of checking the whole format, and moreover just
writes it as is to the commit object.

git-fsck checks for [^<\n]* <[^<>\n]*> format. Note that the
space is mandatory. And the space quirk is already handled via
extending the string to the left when needed.

Modify fast-import input identity format to a slightly stricter
one - deny LF, LT and GT in both <name> and <email>. And check
for it.

This is stricter then git-fsck as fsck accepts "Name> <email>"
currently, but soon fsck check will be adjusted likewise.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: don't fail on omitted committer nameDmitry Ivankov Thu, 11 Aug 2011 10:21:07 +0000 (16:21 +0600)

fast-import: don't fail on omitted committer name

fast-import format declares 'committer_name SP' to be optional in
'committer_name SP LT email GT'. But for a (commit) object SP is
obligatory while zero length committer_name is ok. git-fsck checks
that SP is present, so fast-import must prepend it if the name SP
part is omitted. It doesn't do so and thus for "LT email GT" ident
it writes a bad object.

Name cannot contain LT or GT, ident always comes after SP in fast-import.
So if ident starts with LT reuse the SP as if a valid 'SP LT email GT'
ident was passed.

This fixes a ident parsing bug for a well-formed fast-import input.
Though the parsing is still loose and can accept a ill-formed input.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-import: add input format testsDmitry Ivankov Thu, 11 Aug 2011 10:21:06 +0000 (16:21 +0600)

fast-import: add input format tests

Documentation/git-fast-import.txt says that git-fast-import is strict
about it's input format. But committer/author field parsing is a bit
loose. Invalid values can be unnoticed and written out to the commit,
either with format-conforming input or with non-format-conforming one.

Add one passing and one failing test for empty/absent committer name
with well-formed input. And a failed test with unnoticed ill-formed
input.

Reported-by: SASAKI Suguru <sss.sonik@gmail.com>
Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Reduce parse-options.o dependenciesDmitry Ivankov Thu, 11 Aug 2011 09:15:38 +0000 (15:15 +0600)

Reduce parse-options.o dependencies

Currently parse-options.o pulls quite a big bunch of dependencies.
his complicates it's usage in contrib/ because it pulls external
dependencies and it also increases executables size.

Split off less generic and more internal to git part of
parse-options.c to parse-options-cb.c.

Move prefix_filename function from setup.c to abspath.c. abspath.o
and wrapper.o pull each other, so it's unlikely to increase the
dependencies. It was a dependency of parse-options.o that pulled
many others.

Now parse-options.o pulls just abspath.o, ctype.o, strbuf.o, usage.o,
wrapper.o, libc directly and strlcpy.o indirectly.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

parse-options: export opterr, optbugDmitry Ivankov Thu, 11 Aug 2011 09:15:37 +0000 (15:15 +0600)

parse-options: export opterr, optbug

opterror and optbug functions are used by some of parsing routines
in parse-options.c to report errors and bugs respectively.

Export these functions to allow more custom parsing routines to use
them in a uniform way.

Signed-off-by: Dmitry Ivankov <divanorama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Update draft release notes to 1.7.7Junio C Hamano Thu, 11 Aug 2011 19:12:22 +0000 (12:12 -0700)

Update draft release notes to 1.7.7

Signed-off-by: Junio C Hamano <gitster@pobox.com>

t3900: do not reference numbered arguments from the... Johannes Sixt Thu, 11 Aug 2011 07:05:48 +0000 (09:05 +0200)

t3900: do not reference numbered arguments from the test script

The call to test_expect_success is nested inside a function, whose
arguments the test code wants to access. But it is not specified that any
unexpanded $1, $2, $3, etc in the test code will access the surrounding
function's arguments. Rather, they will access the arguments of the
function that happens to eval the test code.

In this case, the reference is intended to supply '-m message' to a call of
'git commit --squash'. Remove it because -m is optional and the test case
does not check for it. There are tests in t7500 that check combinations of
--squash and -m.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'cb/partial-commit-relative-pathspec'Junio C Hamano Thu, 11 Aug 2011 18:04:28 +0000 (11:04 -0700)

Merge branch 'cb/partial-commit-relative-pathspec'

* cb/partial-commit-relative-pathspec:
commit: allow partial commits with relative paths

Merge branch 'jk/fast-export-quote-path'Junio C Hamano Thu, 11 Aug 2011 18:03:16 +0000 (11:03 -0700)

Merge branch 'jk/fast-export-quote-path'

* jk/fast-export-quote-path:
fast-export: quote paths in output

Merge branch 'rc/maint-http-wrong-free'Junio C Hamano Thu, 11 Aug 2011 18:03:13 +0000 (11:03 -0700)

Merge branch 'rc/maint-http-wrong-free'

* rc/maint-http-wrong-free:
Makefile: some changes for http-related flag documentation
http.c: fix an invalid free()

Conflicts:
Makefile

Merge branch 'rs/grep-function-context'Junio C Hamano Thu, 11 Aug 2011 18:03:09 +0000 (11:03 -0700)

Merge branch 'rs/grep-function-context'

* rs/grep-function-context:
grep: long context options
grep: add option to show whole function as context

Merge branch 'ef/ipv4-connect-error-report'Junio C Hamano Thu, 11 Aug 2011 18:03:06 +0000 (11:03 -0700)

Merge branch 'ef/ipv4-connect-error-report'

* ef/ipv4-connect-error-report:
connect: only log if all attempts failed (ipv4)

am: Document new --exclude=<path> optionmaximilian attems Tue, 9 Aug 2011 15:21:08 +0000 (17:21 +0200)

am: Document new --exclude=<path> option

The --exclude=<path> option is passed down to apply; document it as such.

Signed-off-by: maximilian attems <max@stro.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

bisect: add support for bisecting bare repositoriesJon Seymour Tue, 9 Aug 2011 02:11:54 +0000 (12:11 +1000)

bisect: add support for bisecting bare repositories

This enhances the support for bisecting history in bare repositories.

The "git bisect" command no longer needs to be run inside a repository
with a working tree; it defaults to --no-checkout when run in a bare
repository.

Two tests are included to demonstrate this behaviour.

Suggested-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

helping smart-http/stateless-rpc fetch raceJunio C Hamano Fri, 5 Aug 2011 20:54:06 +0000 (13:54 -0700)

helping smart-http/stateless-rpc fetch race

A request to fetch from a client over smart HTTP protocol is served in
multiple steps. In the first round, the server side shows the set of refs
it has and their values, and the client picks from them and sends "I want
to fetch the history leading to these commits".

When the server tries to respond to this second request, its refs may have
progressed by a push from elsewhere. By design, we do not allow fetching
objects that are not at the tip of an advertised ref, and the server
rejects such a request. The client needs to try again, which is not ideal
especially for a busy server.

Teach upload-pack (which is the workhorse driven by git-daemon and smart
http server interface) that it is OK for a smart-http client to ask for
commits that are not at the tip of any advertised ref, as long as they are
reachable from advertised refs.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

xdiff/xhistogram: drop need for additional variableTay Ray Chuan Mon, 1 Aug 2011 04:20:10 +0000 (12:20 +0800)

xdiff/xhistogram: drop need for additional variable

Having an additional variable (ptr) instead of changing line(1|2) and
count(1|2) was for debugging purposes.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

xdiff/xhistogram: rely on xdl_trim_ends()Tay Ray Chuan Mon, 1 Aug 2011 04:20:09 +0000 (12:20 +0800)

xdiff/xhistogram: rely on xdl_trim_ends()

Do away with reduce_common_start_end() and use xdf->dstart and xdf->dend
set by xdl_trim_ends() that similarly tells us where the first unmatched
line from the start and end occurs.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

xdiff/xhistogram: rework handling of recursed resultsTay Ray Chuan Mon, 1 Aug 2011 04:20:08 +0000 (12:20 +0800)

xdiff/xhistogram: rework handling of recursed results

Previously we were over-complicating matters by trying to combine the
recursed results. Now, terminate immediately if a recursive call failed
and return its result.

Signed-off-by: Tay Ray Chuan <rctay89@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'oa/pull-reflog'Junio C Hamano Mon, 8 Aug 2011 19:33:36 +0000 (12:33 -0700)

Merge branch 'oa/pull-reflog'

* oa/pull-reflog:
pull: remove extra space from reflog message

Conflicts:
git-pull.sh

Merge branch 'ms/reflog-show-is-default'Junio C Hamano Mon, 8 Aug 2011 19:33:35 +0000 (12:33 -0700)

Merge branch 'ms/reflog-show-is-default'

* ms/reflog-show-is-default:
reflog: actually default to subcommand 'show'

Merge branch 'jl/submodule-status-summary-doc'Junio C Hamano Mon, 8 Aug 2011 19:33:35 +0000 (12:33 -0700)

Merge branch 'jl/submodule-status-summary-doc'

* jl/submodule-status-summary-doc:
Documentation/submodule: add command references and update options

Merge branch 'jn/gitweb-config-list-case'Junio C Hamano Mon, 8 Aug 2011 19:33:35 +0000 (12:33 -0700)

Merge branch 'jn/gitweb-config-list-case'

* jn/gitweb-config-list-case:
gitweb: Git config keys are case insensitive, make config search too

Merge branch 'jl/submodule-update-quiet'Junio C Hamano Mon, 8 Aug 2011 19:33:34 +0000 (12:33 -0700)

Merge branch 'jl/submodule-update-quiet'

* jl/submodule-update-quiet:
submodule: update and add must honor --quiet flag

Merge branch 'js/ls-tree-error'Junio C Hamano Mon, 8 Aug 2011 19:33:34 +0000 (12:33 -0700)

Merge branch 'js/ls-tree-error'

* js/ls-tree-error:
Ensure git ls-tree exits with a non-zero exit code if read_tree_recursive fails.
Add a test to check that git ls-tree sets non-zero exit code on error.

Merge branch 'jn/gitweb-system-config'Junio C Hamano Mon, 8 Aug 2011 19:33:34 +0000 (12:33 -0700)

Merge branch 'jn/gitweb-system-config'

* jn/gitweb-system-config:
gitweb: Introduce common system-wide settings for convenience

Merge branch 'jk/reset-reflog-message-fix'Junio C Hamano Mon, 8 Aug 2011 19:33:33 +0000 (12:33 -0700)

Merge branch 'jk/reset-reflog-message-fix'

* jk/reset-reflog-message-fix:
reset: give better reflog messages

Merge branch 'jc/diff-index-refactor'Junio C Hamano Mon, 8 Aug 2011 19:33:33 +0000 (12:33 -0700)

Merge branch 'jc/diff-index-refactor'

* jc/diff-index-refactor:
diff-lib: refactor run_diff_index() and do_diff_cache()
diff-lib: simplify do_diff_cache()

receive-pack: do not overstep command line argument... Junio C Hamano Mon, 8 Aug 2011 19:31:01 +0000 (12:31 -0700)

receive-pack: do not overstep command line argument array

Previous commit added one element to the command line, without
making sure the result fits there.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'maint'Junio C Hamano Mon, 8 Aug 2011 19:24:16 +0000 (12:24 -0700)

Merge branch 'maint'

* maint:
filter-branch: Export variable `workdir' for --commit-filter
Documentation/Makefile: add *.pdf to `clean' target
Documentation: ignore *.pdf files

filter-branch: Export variable `workdir' for --commit... Michael Witten Sun, 7 Aug 2011 02:44:43 +0000 (02:44 +0000)

filter-branch: Export variable `workdir' for --commit-filter

According to `git help filter-branch':

--commit-filter <command>
...
You can use the _map_ convenience function in this filter,
and other convenience functions, too...
...

However, it turns out that `map' hasn't been usable because it depends
on the variable `workdir', which is not propogated to the environment
of the shell that runs the commit-filter <command> because the
shell is created via a simple-command rather than a compound-command
subshell:

@SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
$(git write-tree) $parentstr < ../message > ../map/$commit ||
die "could not write rewritten commit"

One solution is simply to export `workdir'. However, it seems rather
heavy-handed to export `workdir' to the environments of all commands,
so instead this commit exports `workdir' for only the duration of the
shell command in question:

workdir=$workdir @SHELL_PATH@ -c "$filter_commit" "git commit-tree" \
$(git write-tree) $parentstr < ../message > ../map/$commit ||
die "could not write rewritten commit"

Signed-off-by: Michael Witten <mfwitten@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

submodule: take advantage of gettextln and eval_gettextln.Jon Seymour Sun, 7 Aug 2011 11:58:17 +0000 (21:58 +1000)

submodule: take advantage of gettextln and eval_gettextln.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

stash: take advantage of eval_gettextlnJon Seymour Sun, 7 Aug 2011 11:58:16 +0000 (21:58 +1000)

stash: take advantage of eval_gettextln

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

pull: take advantage of eval_gettextlnJon Seymour Sun, 7 Aug 2011 11:58:15 +0000 (21:58 +1000)

pull: take advantage of eval_gettextln

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-am: take advantage of gettextln and eval_gettextln.Jon Seymour Sun, 7 Aug 2011 11:58:14 +0000 (21:58 +1000)

git-am: take advantage of gettextln and eval_gettextln.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

gettext: add gettextln, eval_gettextln to encode common... Jon Seymour Sun, 7 Aug 2011 11:58:13 +0000 (21:58 +1000)

gettext: add gettextln, eval_gettextln to encode common idiom

Currently, if you want to use gettext or eval_gettext to format a message
you may have to add a separate echo statement and a surrounding subshell
in order to interpolate the required trailing new line.

This patch introduces two new helper functions, gettextln and eval_gettextln
which append a trailing newline to the gettext output.

This allows constructions of the form:

if test -s "$GIT_DIR/BISECT_START"
then
(
gettext "You need to give me at least one good and one bad revisions.
(You can use \"git bisect bad\" and \"git bisect good\" for that.)" &&
echo
) >&2
else
...

to be expressed more concisely as:

if test -s "$GIT_DIR/BISECT_START"
then
gettextln "You need to give me at least one good and one bad revisions.
(You can use \"git bisect bad\" and \"git bisect good\" for that.)" >&2
else
...

Acked-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: cope better with use of return for errorsJonathan Nieder Mon, 8 Aug 2011 01:17:09 +0000 (03:17 +0200)

test: cope better with use of return for errors

In olden times, tests would quietly exit the script when they failed
at an inconvenient moment, which was a little disconcerting.
Therefore v0.99.5~24^2~4 (Trapping exit in tests, using return for
errors, 2005-08-10) switched to an idiom of using "return" instead,
wrapping evaluation of test code in a function to make that safe:

test_run_ () {
eval >&3 2>&4 "$1"
eval_ret="$?"
return 0
}

Years later, the implementation of test_when_finished (v1.7.1.1~95,
2010-05-02) and v1.7.2-rc2~1^2~13 (test-lib: output a newline before
"ok" under a TAP harness, 2010-06-24) took advantage of test_run_ as a
place to put code shared by all test assertion functions, without
paying attention to the function's former purpose:

test_run_ () {
...
eval >&3 2>&4 "$1"
eval_ret=$?

if should run cleanup
then
eval >&3 2>&4 "$test_cleanup"
fi
if TAP format requires a newline here
then
echo
fi
return 0
}

That means cleanup commands and the newline to put TAP output at
column 0 are skipped when tests use "return" to fail early. Fix it by
introducing a test_eval_ function to catch the "return", with a
comment explaining the new function's purpose for the next person who
might touch this code.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test: simplify return value of test_run_Jonathan Nieder Mon, 8 Aug 2011 01:15:34 +0000 (03:15 +0200)

test: simplify return value of test_run_

As v0.99.5~24^2~4 (Trapping exit in tests, using return for errors,
2005-08-10) explains, callers to test_run_ (such as test_expect_code)
used to check the result from eval and the return value separately so
tests that fail early could be distinguished from tests that completed
normally with successful (nonzero) status. Eventually tests that
succeed with nonzero status were phased out (see v1.7.4-rc0~65^2~19,
2010-10-03 and especially v1.5.5-rc0~271, 2008-02-01) but the weird
two-return-value calling convention lives on.

Let's get rid of it. The new rule: test_run_ succeeds (returns 0)
if and only if the test succeeded.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation/Makefile: add *.pdf to `clean' targetEmilio G. Cota Mon, 8 Aug 2011 08:33:05 +0000 (04:33 -0400)

Documentation/Makefile: add *.pdf to `clean' target

user-manual.pdf is not removed by `make clean'; fix it.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Documentation: ignore *.pdf filesEmilio G. Cota Mon, 8 Aug 2011 08:33:04 +0000 (04:33 -0400)

Documentation: ignore *.pdf files

user-manual.pdf is generated by the build and therefore
should be ignored by git.

Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revert: Propagate errors upwards from do_pick_commitRamkumar Ramachandra Thu, 4 Aug 2011 10:39:16 +0000 (16:09 +0530)

revert: Propagate errors upwards from do_pick_commit

Currently, revert_or_cherry_pick can fail in two ways. If it
encounters a conflict, it returns a positive number indicating the
intended exit status for the git wrapper to pass on; for all other
errors, it calls die(). The latter behavior is inconsiderate towards
callers, as it denies them the opportunity to recover from errors and
do other things.

After this patch, revert_or_cherry_pick will still return a positive
return value to indicate an exit status for conflicts as before, while
for some other errors, it will print an error message and return -1
instead of die()-ing. The cmd_revert and cmd_cherry_pick are adjusted
to handle the fatal errors by die()-ing themselves.

While the full benefits of this patch will only be seen once all the
"die" calls are replaced with calls to "error", its immediate impact
is to change some "fatal:" messages to say "error:" and to add a new
"fatal: cherry-pick failed" message at the end when the operation
fails.

Inspired-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Jonathan Nieder <jrnieder@gmail.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revert: Introduce --continue to continue the operationRamkumar Ramachandra Thu, 4 Aug 2011 10:39:15 +0000 (16:09 +0530)

revert: Introduce --continue to continue the operation

Introduce a new "git cherry-pick --continue" command which uses the
information in ".git/sequencer" to continue a cherry-pick that stopped
because of a conflict or other error. It works by dropping the first
instruction from .git/sequencer/todo and performing the remaining
cherry-picks listed there, with options (think "-s" and "-X") from the
initial command listed in ".git/sequencer/opts".

So now you can do:

$ git cherry-pick -Xpatience foo..bar
... description conflict in commit moo ...
$ git cherry-pick --continue
error: 'cherry-pick' is not possible because you have unmerged files.
fatal: failed to resume cherry-pick
$ echo resolved >conflictingfile
$ git add conflictingfile && git commit
$ git cherry-pick --continue; # resumes with the commit after "moo"

During the "git commit" stage, CHERRY_PICK_HEAD will aid by providing
the commit message from the conflicting "moo" commit. Note that the
cherry-pick mechanism has no control at this stage, so the user is
free to violate anything that was specified during the first
cherry-pick invocation. For example, if "-x" was specified during the
first cherry-pick invocation, the user is free to edit out the message
during commit time. Note that the "--signoff" option specified at
cherry-pick invocation time is not reflected in the commit message
provided by CHERRY_PICK_HEAD; the user must take care to add
"--signoff" during the "git commit" invocation.

Helped-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revert: Don't implicitly stomp pending sequencer operationRamkumar Ramachandra Thu, 4 Aug 2011 10:39:14 +0000 (16:09 +0530)

revert: Don't implicitly stomp pending sequencer operation

Protect the user from forgetting about a pending sequencer operation
by immediately erroring out when an existing cherry-pick or revert
operation is in progress like:

$ git cherry-pick foo
... conflict ...
$ git cherry-pick moo
error: .git/sequencer already exists
hint: A cherry-pick or revert is in progress
hint: Use --reset to forget about it
fatal: cherry-pick failed

A naive version of this would break the following established ways of
working:

$ git cherry-pick foo
... conflict ...
$ git reset --hard # I actually meant "moo" when I said "foo"
$ git cherry-pick moo

$ git cherry-pick foo
... conflict ...
$ git commit # commit the resolution
$ git cherry-pick moo # New operation

However, the previous patches "reset: Make reset remove the sequencer
state" and "revert: Remove sequencer state when no commits are
pending" make sure that this does not happen.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

revert: Remove sequencer state when no commits are... Ramkumar Ramachandra Thu, 4 Aug 2011 10:39:13 +0000 (16:09 +0530)

revert: Remove sequencer state when no commits are pending

When cherry-pick or revert is called on a list of commits, and a
conflict encountered somewhere in the middle, the data in
".git/sequencer" is required to continue the operation. However, when
a conflict is encountered in the very last commit, the user will have
to "continue" after resolving the conflict and committing just so that
the sequencer state is removed. This is how the current "rebase -i"
script works as well.

$ git cherry-pick foo..bar
... conflict encountered while picking "bar" ...
$ echo "resolved" >problematicfile
$ git add problematicfile
$ git commit
$ git cherry-pick --continue # This would be a no-op

Change this so that the sequencer state is cleared when a conflict is
encountered in the last commit. Incidentally, this patch makes sure
that some existing tests don't break when features like "--reset" and
"--continue" are implemented later in the series.

A better way to implement this feature is to get the last "git commit"
to remove the sequencer state. However, that requires tighter
coupling between "git commit" and the sequencer, a goal that can be
pursued once the sequencer is made more general.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Acked-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

reset: Make reset remove the sequencer stateRamkumar Ramachandra Thu, 4 Aug 2011 10:39:12 +0000 (16:09 +0530)

reset: Make reset remove the sequencer state

Years of muscle memory have trained users to use "git reset --hard" to
remove the branch state after any sort operation. Make it also remove
the sequencer state to facilitate this established workflow:

$ git cherry-pick foo..bar
... conflict encountered ...
$ git reset --hard # Oops, I didn't mean that
$ git cherry-pick quux..bar
... cherry-pick succeeded ...

Guard against accidental removal of the sequencer state by providing
one level of "undo". In the first "reset" invocation,
".git/sequencer" is moved to ".git/sequencer-old"; it is completely
removed only in the second invocation.

Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

fast-export: quote paths in outputJeff King Fri, 5 Aug 2011 22:36:22 +0000 (16:36 -0600)

fast-export: quote paths in output

Many pathnames in a fast-import stream need to be quoted. In
particular:

1. Pathnames at the end of an "M" or "D" line need quoting
if they contain a LF or start with double-quote.

2. Pathnames on a "C" or "R" line need quoting as above,
but also if they contain spaces.

For (1), we weren't quoting at all. For (2), we put
double-quotes around the paths to handle spaces, but ignored
the possibility that they would need further quoting.

This patch checks whether each pathname needs c-style
quoting, and uses it. This is slightly overkill for (1),
which doesn't actually need to quote many characters that
vanilla c-style quoting does. However, it shouldn't hurt, as
any implementation needs to be ready to handle quoted
strings anyway.

In addition to adding a test, we have to tweak a test which
blindly assumed that case (2) would always use
double-quotes, whether it needed to or not.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

filter-branch.sh: de-dent usage stringJunio C Hamano Fri, 5 Aug 2011 22:06:21 +0000 (15:06 -0700)

filter-branch.sh: de-dent usage string

"Usage: git filter-branch " that is prefixed to the first line is 25
columns long, so the "[--index-filter ..." on the second line would not
align with "[--env-filter ..." on the first line to begin with. If the
second and subsequent lines do not aim to align with anything on the
first line, it is just fine to indent them with a single HT.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

misc-sh: fix up whitespace in some other .sh files.Jon Seymour Fri, 5 Aug 2011 13:31:29 +0000 (23:31 +1000)

misc-sh: fix up whitespace in some other .sh files.

I found that the patched 4 files were different when this
filter is applied.

expand -i | unexpand --first-only

This patch contains the corrected files.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

Merge branch 'tc/minix'Junio C Hamano Fri, 5 Aug 2011 21:55:00 +0000 (14:55 -0700)

Merge branch 'tc/minix'

* tc/minix:
Makefile: add Minix configuration options.

Merge branch 'jc/pack-order-tweak'Junio C Hamano Fri, 5 Aug 2011 21:54:57 +0000 (14:54 -0700)

Merge branch 'jc/pack-order-tweak'

* jc/pack-order-tweak:
pack-objects: optimize "recency order"
core: log offset pack data accesses happened

bisect: further style nitpicksJunio C Hamano Fri, 5 Aug 2011 17:09:23 +0000 (10:09 -0700)

bisect: further style nitpicks

Fix a few remaining lines that indented with spaces.

Also simplify the logic of checking out the original branch and reporting
error during "bisect reset".

Signed-off-by: Junio C Hamano <gitster@pobox.com>

bisect: replace "; then" with "\n<tab>*then"Jon Seymour Fri, 5 Aug 2011 11:31:31 +0000 (21:31 +1000)

bisect: replace "; then" with "\n<tab>*then"

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

bisect: cleanup whitespace errors in git-bisect.sh.Jon Seymour Fri, 5 Aug 2011 11:31:30 +0000 (21:31 +1000)

bisect: cleanup whitespace errors in git-bisect.sh.

All leading whitespace is now encoded with tabs.

After this patch, the following is true:

RAW=$(cat git-bisect.sh | md5sum) &&
ROUNDTRIP=$(cat git-bisect.sh | expand -i - | unexpand --first-only - | md5sum) &&
LEADING=$(sed -n "/^ */p" < git-bisect.sh | wc -l) &&
test $RAW = $ROUNDTRIP &&
test $LEADING = 0 &&
test -z "$(git diff -w HEAD~1 HEAD)"

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-path-utils: Add subcommand "prefix_path"Michael Haggerty Thu, 4 Aug 2011 04:47:48 +0000 (06:47 +0200)

test-path-utils: Add subcommand "prefix_path"

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

test-path-utils: Add subcommand "absolute_path"Michael Haggerty Thu, 4 Aug 2011 04:47:47 +0000 (06:47 +0200)

test-path-utils: Add subcommand "absolute_path"

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-check-attr: Normalize pathsMichael Haggerty Thu, 4 Aug 2011 04:47:46 +0000 (06:47 +0200)

git-check-attr: Normalize paths

Normalize the path arguments (relative to the working tree root, if
applicable) before looking up their attributes. This requires passing
the prefix down the call chain.

This fixes two test cases for different reasons:

* "unnormalized paths" is fixed because the .gitattribute-file-seeking
code is not confused into reading the top-level file twice.

* "relative paths" is fixed because the canonical pathnames are passed
to get_check_attr() or get_all_attrs(), allowing them to match the
pathname patterns as expected.

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-check-attr: Demonstrate problems with relative... Michael Haggerty Thu, 4 Aug 2011 04:47:45 +0000 (06:47 +0200)

git-check-attr: Demonstrate problems with relative paths

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

git-check-attr: Demonstrate problems with unnormalized... Michael Haggerty Thu, 4 Aug 2011 04:47:44 +0000 (06:47 +0200)

git-check-attr: Demonstrate problems with unnormalized paths

Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>