Commit graph

1856 commits

Author SHA1 Message Date
Kevin Ballard 6b2fbaaffc format-patch: Produce better output with --inline or --attach
This patch makes two small changes to improve the output of --inline
and --attach.

The first is to write a newline preceding the boundary. This is needed because
MIME defines the encapsulation boundary as including the preceding CRLF (or in
this case, just LF), so we should be writing one. Without this, the last
newline in the pre-diff content is consumed instead.

The second change is to always write the line termination character
(default: newline) even when using --inline or --attach. This is simply to
improve the aesthetics of the resulting message. When using --inline an email
client should render the resulting message identically to the non-inline
version. And when using --attach this adds a blank line preceding the
attachment in the email, which is visually attractive.

Signed-off-by: Kevin Ballard <kevin@sb.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-29 23:18:15 -07:00
Junio C Hamano 65c35b2256 t7001: fix "git mv" test
The test assumed that we can keep the cached stat information fresh across
rename(2); many filesystems however update st_ctime (and POSIX allows them
to do so), and that assumption does not hold.

We can explicitly refresh the index for the purpose of these tests.  The
only thing we are interested in is the staged contents and the mode bits
are preserved across "git mv".

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-28 23:02:12 -07:00
Jeff King 172035f044 init: handle empty "template" parameter
If a user passes "--template=", then our template parameter
is blank. Unfortunately, copy_templates() assumes it has at
least one character, and does all sorts of bad things like
reading from template[-1] and then proceeding to link all of
'/' into the .git directory.

This patch just checks for that condition in copy_templates
and aborts. As a side effect, this means that --template=
now has the meaning "don't copy any templates."

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-27 23:14:03 -07:00
Petr Baudis 81dc2307d0 git-mv: Keep moved index entries inact
The rewrite of git-mv from a shell script to a builtin was perhaps
a little too straightforward: the git add and git rm queues were
emulated directly, which resulted in a rather complicated code and
caused an inconsistent behaviour when moving dirty index entries;
git mv would update the entry based on working tree state,
except in case of overwrites, where the new entry would still have
sha1 of the old file.

This patch introduces rename_index_entry_at() into the index toolkit,
which will rename an entry while removing any entries the new entry
might render duplicate. This is then used in git mv instead
of all the file queues, resulting in a major simplification
of the code and an inevitable change in git mv -n output format.

Also the code used to refuse renaming overwriting symlink with a regular
file and vice versa; there is no need for that.

A few new tests have been added to the testsuite to reflect this change.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-27 15:05:19 -07:00
Björn Steinbrink 2122f8b963 rev-parse: Add support for the ^! and ^@ syntax
Those shorthands are explained in the rev-parse documentation but were not
actually supported by rev-parse itself.

gitk internally uses rev-parse to interpret its command line arguments, and
being able to use these "limit with parents" syntax is handy there.

Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-27 14:14:01 -07:00
Junio C Hamano 47c6ef1c8d make sure parsed wildcard refspec ends with slash
A wildcard refspec is internally parsed into a refspec structure with src
and dst strings.  Many parts of the code assumed that these do not include
the trailing "/*" when matching the wildcard pattern with an actual ref we
see at the remote.  What this meant was that we needed to make sure not
just that the prefix matched, and also that a slash followed the part that
matched.

But a codepath that scans the result from ls-remote and finds matching
refs forgot to check the "matching part must be followed by a slash" rule.
This resulted in "refs/heads/b1" from the remote side to mistakenly match
the source side of "refs/heads/b/*:refs/remotes/b/*" refspec.

Worse, the refspec crafted internally by "git-clone", and a hardcoded
preparsed refspec that is used to implement "git-fetch --tags", violated
this "parsed widcard refspec does not end with slash" rule; simply adding
the "matching part must be followed by a slash" rule then would have
broken codepaths that use these refspecs.

This commit changes the rule to require a trailing slash to parsed
wildcard refspecs.  IOW, "refs/heads/b/*:refs/remotes/b/*" is parsed as
src = "refs/heads/b/" and dst = "refs/remotes/b/".  This allows us to
simplify the matching logic because we only need to do a prefixcmp() to
notice "refs/heads/b/one" matches and "refs/heads/b1" does not.

Acked-by: Daniel Barkalow <barkalow@iabervon.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-27 14:14:01 -07:00
Jonathan Nieder b890fa33a4 t6030 (bisect): work around Mac OS X "ls"
t6030-bisect-porcelain.sh relies on "ls" exiting with nonzero
status when asked to list nonexistent files.  Unfortunately,
/bin/ls on Mac OS X 10.3 exits with exit code 0.  So look at
its output instead.

Signed-off-by: Jonathan Nieder <jrnieder@uchicago.edu>
Acked-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-27 14:14:01 -07:00
Brad King 128de65767 git-svn: teach dcommit about svn auto-props
Subversion repositories often require files to have properties such as
svn:mime-type and svn:eol-style set when they are added.  Users
typically set these properties automatically using the SVN auto-props
feature with 'svn add'.  This commit teaches dcommit to look at the user
SVN configuration and apply matching auto-props entries for files added
by a diff as it is applied to the SVN remote.

Signed-off-by: Brad King <brad.king@kitware.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 17:54:19 -07:00
Steve Haslam 837c876713 Propagate -u/--upload-pack option of "git clone" to transport.
The -u option to override the remote system's path to git-upload-pack was
being ignored by "git clone"; caused by a missing call to
transport_set_option to set TRANS_OPT_UPLOADPACK. Presumably this crept in
when git-clone was converted from shell to C.

Signed-off-by: Steve Haslam <shaslam@lastminute.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 17:10:14 -07:00
Junio C Hamano d9d9e6ee63 Merge branch 'maint'
* maint:
  Makefile: fix shell quoting
  tests: propagate $(TAR) down from the toplevel Makefile
  index-pack.c: correctly initialize appended objects
  send-email: find body-encoding correctly
2008-07-25 13:56:36 -07:00
Junio C Hamano bfce5087ee Makefile: fix shell quoting
Makefile records paths to a few programs in GIT-BUILD-OPTIONS file.  These
paths need to be quoted twice: once to protect specials from the shell
that runs the generated GIT-BUILD-OPTIONS file, and again to protect them
(and the first level of quoting itself) from the shell that runs the
"echo" inside the Makefile.

You can test this by trying:

    $ ln -s /bin/tar "$HOME/Tes' program/tar"
    $ make TAR="$HOME/Tes' program/tar" test

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 12:36:16 -07:00
Junio C Hamano c30e699fc5 tests: propagate $(TAR) down from the toplevel Makefile
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-25 11:09:48 -07:00
Junio C Hamano 99ea66ec47 Merge branch 'ph/checkout'
* ph/checkout:
  git-checkout: improve error messages, detect ambiguities.
  git-checkout: fix command line parsing.
2008-07-24 23:24:17 -07:00
Pierre Habouzit 859fdabaed git-checkout: improve error messages, detect ambiguities.
The patch is twofold: it moves the option consistency checks just under
the parse_options call so that it doesn't get in the way of the tree
reference vs. pathspecs desambiguation.

The other part rewrites the way to understand arguments so that when
git-checkout fails it does with an understandable message. Compared to the
previous behavior we now have:

  - a better error message when doing:

        git checkout <blob reference> --

    now complains about the reference not pointing to a tree, instead of
    things like:

        error: pathspec <blob reference> did not match any file(s) known to git.
        error: pathspec '--' did not match any file(s) known to git.

  - a better error message when doing:

        git checkout <path> --

    It now complains about <path> not being a reference instead of the
    completely obscure:

        error: pathspec '--' did not match any file(s) known to git.

  - an error when -- wasn't used, and the first argument is ambiguous
    (i.e. can be interpreted as both ref and as path).

Signed-off-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-24 23:24:00 -07:00
Olivier Marin 9944d1a0e4 update test case to protect am --skip behaviour
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-24 23:09:09 -07:00
Petr Baudis a4661b018d git-filter-branch.sh: Allow running in bare repositories
Commit 46eb449c restricted git-filter-branch to non-bare repositories
unnecessarily; git-filter-branch can work on bare repositories just
fine.

Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 16:57:04 -07:00
Stephan Beyer c8fe1980b2 git-am: Add colon before the subject that is printed out as being applied
git-am output can be confusing, because the subject of the applied
patch can look like the rest of a sentence starting with "Applying".
The added colon should make this clearer.

Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 12:31:37 -07:00
Johannes Schindelin e358f3c31e sort_in_topological_order(): avoid setting a commit flag
We used to set the TOPOSORT flag of commits during the topological
sorting, but we can just as well use the member "indegree" for it:
indegree is now incremented by 1 in the cases where the commit used
to have the TOPOSORT flag.

This is the same behavior as before, since indegree could not be
non-zero when TOPOSORT was unset.

Incidentally, this fixes the bug in show-branch where the 8th column
was not shown: show-branch sorts the commits in topological order,
assuming that all the commit flags are available for show-branch's
private matters.

But this was not true: TOPOSORT was identical to the flag corresponding
to the 8th ref.  So the flags for the 8th column were unset by the
topological sorting.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 12:00:21 -07:00
Johannes Schindelin ce567d1867 Add test to show that show-branch misses out the 8th column
Noticed by Pasky.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:52:21 -07:00
Brandon Casey c65233fe2c t/t4202-log.sh: add newline at end of file
Some shells hang when parsing the script if the last statement is not
followed by a newline. So add one.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:36:41 -07:00
Brandon Casey 09b78bc1fc t7502-commit.sh: rearrange test to make more portable
Some shells have problems with one-shot environment variable export
and function calls. The sequence is rearranged to avoid the one-shot
and to allow the test script to be linked together with '&&'.

Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:36:31 -07:00
Brandon Casey 03b9dfb18b t3200,t7201: replace '!' with test_must_fail
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:35:23 -07:00
Brandon Casey 9a885fac0d t4116-apply-reverse.sh: use $TAR rather than tar
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:35:16 -07:00
Brandon Casey 2b14d07237 t/: Replace diff [-u|-U0] with test_cmp to allow compilation with old diff
Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:35:01 -07:00
Miklos Vajna 4d175ef71d t7601: extend the 'merge picks up the best result' test
The test only checked if the best result picking code works if there are
multiple strategies set in the config. Add a similar one that tests if
the same true if the -s option of git merge was used multiple times.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-23 11:33:40 -07:00
Olivier Marin 95f8ebbfc7 git am --skip: clean the index while preserving local changes
In 3-way merge, "am" will let the index with unmerged path waiting
for us to resolve conflicts and continue. But if we want to --skip
instead, "am" refuses to continue because of the dirty index.

With this patch, "am" will clean the index without touching files
locally modified, before continuing.

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-22 00:06:04 -07:00
Miklos Vajna 1719b5e446 builtin-merge: give a proper error message for invalid strategies in config
'git merge -s foobar' diagnosed invalid "foobar" strategy and errored out
with a message, but foobar in pull.twohead or pull.octopus was just
silently ignored.  This makes invalid strategy both on the command line
and in the configuration file to trigger the same error.

Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 22:29:46 -07:00
Junio C Hamano ac2e28c0a4 tests: do not rely on external "patch"
Some of our tests assumed a working "patch" command to produce expected
results when checking "git-apply", but some systems have broken "patch".

We can compare our output with expected output that is precomputed
instead to sidestep this issue.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 21:33:16 -07:00
Olivier Marin d5d745f90b parse-options: fix segmentation fault when a required value is missing
p->argc represent the number of arguments that have not been parsed yet,
_including_ the one we are currently parsing. If it is not greater than
one then there is no more argument.

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Acked-by: Pierre Habouzit <madcoder@debian.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 21:20:04 -07:00
Johannes Schindelin 51ef1daa4a Rename .git/rebase to .git/rebase-apply
With git-am, it sounds awkward to have the patches in ".git/rebase/",
but for technical reasons, we have to keep the same directory name
for git-am and git-rebase. ".git/rebase-apply" seems to be a good
compromise.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-21 18:51:47 -07:00
Junio C Hamano 245648dede Merge branch 'ns/am-abort'
* ns/am-abort:
  git am --abort
2008-07-20 18:00:13 -07:00
Junio C Hamano 378335b37c Merge branch 'jc/add-addremove'
* jc/add-addremove:
  git-add --all: documentation
  git-add --all: tests
  git-add --all: add all files
  builtin-add.c: restructure the code for maintainability

Conflicts:
	builtin-add.c
2008-07-20 17:53:17 -07:00
Junio C Hamano d14e7407b3 "needs update" considered harmful
"git update-index --refresh", "git reset" and "git add --refresh" have
reported paths that have local modifications as "needs update" since the
beginning of git.

Although this is logically correct in that you need to update the index at
that path before you can commit that change, it is now becoming more and
more clear, especially with the continuous push for user friendliness
since 1.5.0 series, that the message is suboptimal.  After all, the change
may be something the user might want to get rid of, and "updating" would
be absolutely a wrong thing to do if that is the case.

I prepared two alternatives to solve this.  Both aim to reword the message
to more neutral "locally modified".

This patch is a more intrusive variant that changes the message for only
Porcelain commands ("add" and "reset") while keeping the plumbing
"update-index" intact.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20 17:21:32 -07:00
Junio C Hamano fa4946b553 Merge branch 'maint'
* maint:
  fix usage string for git grep
  refresh-index: fix bitmask assignment

Conflicts:
	builtin-grep.c
2008-07-20 17:16:29 -07:00
Michele Ballabio 74f5b7fba4 builtin-merge.c: Fix option parsing
Now "git merge -m" needs a message, and errors out with the usage
text if none is given.
This way, t7600-merge.sh is fixed.

Signed-off-by: Michele Ballabio <barra_cuda@katamail.com>
Acked-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20 13:37:26 -07:00
Lars Noschinski b0f2ecf593 cvsserver: Add testsuite for packed refs
Check that req_update shows refs, even if all refs are packed.

Signed-off-by: Lars Noschinski <lars@public.noschinski.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20 11:24:44 -07:00
Junio C Hamano 3f1b7b607a refresh-index: fix bitmask assignment
5fdeacb (Teach update-index about --ignore-submodules, 2008-05-14) added a
new refresh option flag but did not assign a unique bit for it correctly,
and broke "update-index --ignore-missing".

This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-20 00:00:46 -07:00
Junio C Hamano 340ce9e25f git-add --all: tests
And here is a small test script that makes sure that:

 - both modified and new files are included,
 - removed file is noticed, and
 - no ignored file is included.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 23:08:58 -07:00
Nanako Shiraishi 3e5057a8b4 git am --abort
After failing to apply patches in the middle of a series, "git am --abort"
lets you go back to the original commit.

[jc: doc/help update from Olivier, and fixups for "am -3" squashed in]

Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 15:26:28 -07:00
Junio C Hamano 679639904d Merge branch 'maint'
* maint:
  GIT 1.5.6.4
  builtin-rm: fix index lock file path
  http-fetch: do not SEGV after fetching a bad pack idx file
  rev-list: honor --quiet option
  api-run-command.txt: typofix
2008-07-19 11:28:06 -07:00
Alexander Gavrilov 03db4525d3 Support gitlinks in fast-import.
Currently fast-import/export cannot be used for
repositories with submodules. This patch extends
the relevant programs to make them correctly
process gitlinks.

Links can be represented by two forms of the
Modify command:

M 160000 SHA1 some/path

which sets the link target explicitly, or

M 160000 :mark some/path

where the mark refers to a commit. The latter
form can be used by importing tools to build
all submodules simultaneously in one physical
repository, and then simply fetch them apart.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 11:25:51 -07:00
Fabian Emmes 42f7a2dae8 testsuite for cvs co -c
Check that all branches are displayed.

Signed-off-by: Fabian Emmes <fabian.emmes@rwth-aachen.de>
Signed-off-by: Lars Noschinski <lars@public.noschinski.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 11:17:43 -07:00
Fabian Emmes 374488f31d Testsuite: Unset CVS_SERVER
The CVS_SERVER environment variable can cause some of the cvsimport tests
to fail. So unset this variable at the beginning of the test script.

Signed-off-by: Fabian Emmes <fabian.emmes@rwth-aachen.de>
Signed-off-by: Lars Noschinski <lars@public.noschinski.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 11:17:42 -07:00
Junio C Hamano bb3e4f03be t9001 (send-email): Do not use hardcoded /bin/sh in test
Scriptlets used form inside this test began with hardcoded "#!/bin/sh".
By setting SHELL_PATH the user is already telling us that what the vendor
has in /bin/sh isn't POSIX enough, and we really should try to honor that
request.

Originally noticed by SungHyun Nam who later tested this patch and
verified that it fixes the issue on Solaris 9.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 11:17:42 -07:00
Olivier Marin 4d26467279 builtin-rm: fix index lock file path
When hold_locked_index() is called with a relative git_dir and you are
outside the work tree, the lock file become relative to the current
directory. So when later setup_work_tree() change the current directory
it breaks lock file path and commit_locked_index() fails.

This patch move index locking code after setup_work_tree() call to make
lock file relative to the working tree as it should be and add a test
case.

Noticed by Nick Andrew.

Signed-off-by: Olivier Marin <dkr@freesurf.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-19 10:41:17 -07:00
Junio C Hamano 1f8dc67155 Merge branch 'mv/dashless'
* mv/dashless:
  make remove-dashes: apply to scripts and programs as well, not just to builtins
  git-bisect: use dash-less form on git bisect log
  t1007-hash-object.sh: use quotes for the test description
  t0001-init.sh: change confusing directory name
2008-07-16 17:49:59 -07:00
Junio C Hamano 588c038ac6 Merge branch 'sb/dashless'
* sb/dashless:
  Make usage strings dash-less
  t/: Use "test_must_fail git" instead of "! git"
  t/test-lib.sh: exit with small negagive int is ok with test_must_fail

Conflicts:
	builtin-blame.c
	builtin-mailinfo.c
	builtin-mailsplit.c
	builtin-shortlog.c
	git-am.sh
	t/t4150-am.sh
	t/t4200-rerere.sh
2008-07-16 17:22:50 -07:00
Junio C Hamano 88bbda08d7 Merge branch 'maint'
* maint:
  Start preparing 1.5.6.4 release notes
  git fetch-pack: do not complain about "no common commits" in an empty repo
  rebase-i: keep old parents when preserving merges
  t7600-merge: Use test_expect_failure to test option parsing
  Fix buffer overflow in prepare_attr_stack
  Fix buffer overflow in git diff
  Fix buffer overflow in git-grep
  git-cvsserver: fix call to nonexistant cleanupWorkDir()
  Documentation/git-cherry-pick.txt et al.: Fix misleading -n description

Conflicts:
	RelNotes
2008-07-16 17:10:28 -07:00
Junio C Hamano 614de95c76 Merge branch 'ls/maint-mailinfo-patch-label' into maint
* ls/maint-mailinfo-patch-label:
  git-mailinfo: Fix getting the subject from the in-body [PATCH] line
2008-07-16 15:23:19 -07:00
Johannes Sixt 01941bd543 t7600-merge: Use test_expect_failure to test option parsing
It used plain 'if git merge ...', which hides a segfault. The test does not pass.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-07-16 14:27:09 -07:00