1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-08 02:03:12 +01:00
Commit graph

16795 commits

Author SHA1 Message Date
Linus Torvalds
9e8eceab73 Add 'merge' mode to 'git reset'
We have always had a nice way to reset a working tree to another state
while carrying our changes around: "git read-tree -u -m". Yes, it fails if
the target tree is different in the paths that are dirty in the working
tree, but this is how we used to switch branches in "git checkout", and it
worked fine.

However, perhaps exactly _because_ we've supported this from very early
on, another low-level command, namely "git reset", never did.

But as time went on, 'git reset' remains as a very common command, while
'git read-tree' is now a very odd and low-level plumbing thing that nobody
sane should ever use, because it only makes sense together with other
operations like either switching branches or just rewriting HEAD.

Which means that we have effectively lost the ability to do something very
common: jump to another point in time without always dropping all our
dirty state.

So add this kind of mode to "git reset", and since it merges your changes
to what you are resetting to, just call it that: "git reset --merge".

I've wanted this for a long time, since I very commonly carry a dirty
tree while working on things. My main 'Makefile' file quite often has the
next version already modified, and sometimes I have local modifications
that I don't want to commit, but I still do pulls and patch applications,
and occasionally want to do "git reset" to undo them - while still keeping
my local modifications.

(Maybe we could eventually change it to something like "if we have a
working tree, default to --merge, otherwise default to --mixed").

NOTE! This new mode is certainly not perfect. There's a few things to look
out for:

 - if the index has unmerged entries, "--merge" will currently simply
   refuse to reset ("you need to resolve your current index first").
   You'll need to use "--hard" or similar in this case.

   This is sad, because normally a unmerged index means that the working
   tree file should have matched the source tree, so the correct action is
   likely to make --merge reset such a path to the target (like --hard),
   regardless of dirty state in-tree or in-index. But that's not how
   read-tree has ever worked, so..

 - "git checkout -m" actually knows how to do a three-way merge, rather
   than refuse to update the working tree. So we do know how to do that,
   and arguably that would be even nicer behavior.

   At the same time it's also arguably true that there is a chance of loss
   of state (ie you cannot get back to the original tree if the three-way
   merge ends up resolving cleanly to no diff at all), so the "refuse to
   do it" is in some respects the safer - but less user-friendly - option.

In other words, I think 'git reset --merge' could become a bit more
friendly, but this is already a big improvement. It allows you to undo a
recent commit without having to throw your current work away.

Yes, yes, with a dirty tree you could always do

	git stash
	git reset --hard
	git stash apply

instead, but isn't "git reset --merge" a nice way to handle one particular
simple case?

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
--

Hmm? Maybe I'm the only one that does a lot of work with a dirty tree, and
sure, I can do other things like the "git stash" thing, or using "git
checkout" to actually create a new branch, and then playing games with
branch renaming etc to make it work like this one.

But I suspect others dislike how "git reset" works too. But see the
suggested improvements above.

 builtin-reset.c |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)
2008-12-02 15:15:58 -08:00
Junio C Hamano
3273ebc759 GIT 1.6.1-rc1
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-01 00:55:19 -08:00
Junio C Hamano
aaab7ea3cd Include git-gui--askpass in git-gui RPM package
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-12-01 00:54:16 -08:00
Junio C Hamano
39a76bdd7d Merge git://git.kernel.org/pub/scm/gitk/gitk
* git://git.kernel.org/pub/scm/gitk/gitk:
  gitk: Avoid handling the Return key twice in Add Branch
  gitk: Show local changes properly when we have a path limit
  gitk: Fix switch statement in parseviewargs
  gitk: Index line[hnd]tag arrays by id rather than row number
2008-11-30 22:59:41 -08:00
Junio C Hamano
363cfc1716 Merge git://repo.or.cz/git-gui
* git://repo.or.cz/git-gui:
  git-gui: update Japanese translation
  git-gui: french translation update
  Updated Swedish translation (514t0f0u).
  git gui: update Italian translation
  Update Hungarian translation. 100% completed.
2008-11-30 22:54:39 -08:00
Junio C Hamano
69f4ce5537 send-email: do not reverse the command line arguments
The loop picks elements from @ARGV one by one, sifts them into arguments
meant for format-patch and the script itself, and pushes them to @files
and @rev_list_opts arrays.  Pick elements from @ARGV starting at the
beginning using shift, instead of at the end using pop, as push appends
them to the end of the array.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-30 22:38:20 -08:00
Junio C Hamano
7f871c6ecc Merge branch 'maint'
* maint:
  Update draft release notes to 1.6.0.5
  generate-cmdlist.sh: avoid selecting synopsis at wrong place
2008-11-30 18:43:56 -08:00
Junio C Hamano
5359fde8a4 Update draft release notes to 1.6.0.5
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-30 18:33:20 -08:00
Junio C Hamano
27f64962f1 Merge branch 'st/maint-tag' into maint
* st/maint-tag:
  tag: Add more tests about mixing incompatible modes and options
  tag: Check that options are only allowed in the appropriate mode
2008-11-30 18:18:50 -08:00
Junio C Hamano
270c35490a Merge branch 'mk/maint-cg-push' into maint
* mk/maint-cg-push:
  git push: Interpret $GIT_DIR/branches in a Cogito compatible way
2008-11-30 18:18:11 -08:00
Nguyễn Thái Ngọc Duy
16d258332e generate-cmdlist.sh: avoid selecting synopsis at wrong place
In "common" man pages there is luckily no "NAME" anywhere except at
beginning of documents. If there is another "NAME", sed could
mis-select it and lead to common-cmds.h corruption. So better nail it
at beginning of line, which would reduce corruption chance.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-30 18:16:32 -08:00
Junio C Hamano
d5cbdba843 Merge branch 'cc/bisect-skip'
* cc/bisect-skip:
  bisect: teach "skip" to accept special arguments like "A..B"
2008-11-27 19:25:25 -08:00
Junio C Hamano
8c1944dd34 Merge branch 'js/mingw-rename-fix'
* js/mingw-rename-fix:
  compat/mingw.c: Teach mingw_rename() to replace read-only files
2008-11-27 19:25:06 -08:00
Junio C Hamano
ef4daa74af Merge branch 'st/levenshtein'
* st/levenshtein:
  Document levenshtein.c
  Fix deletion of last character in levenshtein distance
2008-11-27 19:24:47 -08:00
Junio C Hamano
cab7d7d827 Merge branch 'cr/remote-update-v'
* cr/remote-update-v:
  git-remote: add verbose mode to git remote update
2008-11-27 19:24:40 -08:00
Junio C Hamano
2d2b3fd848 Merge branch 'rs/strbuf-expand'
* rs/strbuf-expand:
  remove the unused files interpolate.c and interpolate.h
  daemon: deglobalize variable 'directory'
  daemon: inline fill_in_extra_table_entries()
  daemon: use strbuf_expand() instead of interpolate()
  merge-recursive: use strbuf_expand() instead of interpolate()
  add strbuf_expand_dict_cb(), a helper for simple cases
2008-11-27 19:24:36 -08:00
Junio C Hamano
14de7393f1 Merge branch 'mv/clone-strbuf'
* mv/clone-strbuf:
  builtin_clone: use strbuf in cmd_clone()
  builtin-clone: use strbuf in clone_local() and copy_or_link_directory()
  builtin-clone: use strbuf in guess_dir_name()
2008-11-27 19:24:25 -08:00
Junio C Hamano
2af9664776 Merge branch 'lt/preload-lstat'
* lt/preload-lstat:
  Fix index preloading for racy dirty case
  Add cache preload facility
2008-11-27 19:24:13 -08:00
Junio C Hamano
98cdf78c5c Merge branch 'ta/quiet-pull'
* ta/quiet-pull:
  Retain multiple -q/-v occurrences in git pull
  Teach/Fix pull/fetch -q/-v options
2008-11-27 19:24:11 -08:00
Junio C Hamano
496db64202 Merge branch 'ph/send-email'
* ph/send-email:
  git send-email: ask less questions when --compose is used.
  git send-email: add --annotate option
  git send-email: interpret unknown files as revision lists
  git send-email: make the message file name more specific.
2008-11-27 19:24:00 -08:00
Junio C Hamano
455d0f5c23 Merge branch 'maint'
* maint:
  sha1_file.c: resolve confusion EACCES vs EPERM
  sha1_file: avoid bogus "file exists" error message
  git checkout: don't warn about unborn branch if -f is already passed
  bash: offer refs instead of filenames for 'git revert'
  bash: remove dashed command leftovers
  git-p4: fix keyword-expansion regex
  fast-export: use an unsorted string list for extra_refs
  Add new testcase to show fast-export does not always exports all tags
2008-11-27 19:23:51 -08:00
Junio C Hamano
539eec48f0 Merge branch 'mv/fast-export' into maint
* mv/fast-export:
  fast-export: use an unsorted string list for extra_refs
  Add new testcase to show fast-export does not always exports all tags
2008-11-27 19:23:27 -08:00
Sam Vilain
35243577ab sha1_file.c: resolve confusion EACCES vs EPERM
An earlier commit 916d081 (Nicer error messages in case saving an object
to db goes wrong, 2006-11-09) confused EACCES with EPERM, the latter of
which is an unlikely error from mkstemp().

Signed-off-by: Sam Vilain <sam@vilain.net>
2008-11-27 19:11:21 -08:00
Joey Hess
65117abc04 sha1_file: avoid bogus "file exists" error message
This avoids the following misleading error message:

error: unable to create temporary sha1 filename ./objects/15: File exists

mkstemp can fail for many reasons, one of which, ENOENT, can occur if
the directory for the temp file doesn't exist. create_tmpfile tried to
handle this case by always trying to mkdir the directory, even if it
already existed. This caused errno to be clobbered, so one cannot tell
why mkstemp really failed, and it truncated the buffer to just the
directory name, resulting in the strange error message shown above.

Note that in both occasions that I've seen this failure, it has not been
due to a missing directory, or bad permissions, but some other, unknown
mkstemp failure mode that did not occur when I ran git again. This code
could perhaps be made more robust by retrying mkstemp, in case it was a
transient failure.

Signed-off-by: Joey Hess <joey@kitenet.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 18:48:53 -08:00
Matt McCutchen
1510dbe380 git checkout: don't warn about unborn branch if -f is already passed
I think it's unnecessary to warn that the checkout has been forced due to an
unborn current branch if -f has been explicitly passed.  For one project, I am
using git-new-workdir to create workdirs from a bare repository whose HEAD is
set to an unborn branch, and this warning started to irritate me.

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 18:35:28 -08:00
SZEDER Gábor
c07838371b bash: offer refs instead of filenames for 'git revert'
The completion script for 'git revert' currently offers options and
filenames.  However, 'git revert' doesn't take any filenames from the
command line, but a single commit.  Therefore, it's more sane to offer
refs instead.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 18:35:07 -08:00
SZEDER Gábor
608efb875f bash: complete full refs
Sometimes it's handy to complete full refs, e.g. the user has some
refs outside of refs/{heads,remotes,tags} or the user wants to
complete some git command's special refs (like 'git show
refs/bisect/bad').

To do that, we check whether the ref to be completed starts with
'refs/' or is 'refs' (to reduce the risk of matching 'refs-').  If it
does, then we offer full refs for completion; otherwise everything
works as usual.

This way the impact on the common case is fairly small (hopefully not
many users have branches or tags starting with 'refs'), and in the
special case the cost of typing out 'refs' is bearable.

While at it, also remove the unused 'cmd' variable from '__git_refs'.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 18:34:30 -08:00
SZEDER Gábor
8d8163f377 bash: remove dashed command leftovers
Commit 5a625b07 (bash: remove fetch, push, pull dashed form leftovers,
2008-10-03) did that already, but there were still some git-cmd left
here and there.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Acked-by: Shawn O. Pearce <spearce@spearce.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 18:29:53 -08:00
Junio C Hamano
b21a226a42 Merge branch 'pw/maint-p4' into maint
* pw/maint-p4:
  git-p4: fix keyword-expansion regex
2008-11-27 13:18:25 -08:00
Pete Wyckoff
3d51c853df git-p4: fix keyword-expansion regex
This text:

     my $dir = $File::Find::dir;
     return if ($dir !~ m,$options->{dirpat}$,);

was improperly converted to:

     my $dir = $File$dir !~ m,$options->{dirpat}$,);

by the keyword identifier expansion code.  Add a \n
to make sure the regex doesn't go across end-of-line
boundaries.

Signed-off-by: Pete Wyckoff <pw@padd.com>
Acked-by: Simon Hausmann <simon@lst.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 13:17:58 -08:00
Ralf Wildenhues
76bac89036 Fix typos in the documentation.
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 01:17:23 -08:00
Junio C Hamano
c0a4ae5caf Merge branch 'rw/maint-typofix' into rw/typofix
* rw/maint-typofix:
  Fix typos in the documentation.
2008-11-27 01:17:09 -08:00
Ralf Wildenhues
a0178ae2cf Fix typos in the documentation.
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-27 01:00:45 -08:00
Nanako Shiraishi
6249067c61 git-gui: update Japanese translation
Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2008-11-26 14:13:30 -08:00
Junio C Hamano
aa14a0c3f1 Merge branch 'maint'
* maint:
  Teach "git diff" to honour --[no-]ext-diff
2008-11-26 11:57:31 -08:00
Junio C Hamano
78a0014d80 Merge branch 'mm/sort-config-doc'
* mm/sort-config-doc:
  config.txt: alphabetize configuration sections
2008-11-26 11:57:28 -08:00
Junio C Hamano
5aa3bdd50d Merge branch 'mm/maint-sort-config-doc' into maint
* mm/maint-sort-config-doc:
  config.txt: alphabetize configuration sections
2008-11-26 11:57:15 -08:00
Junio C Hamano
42fc11c110 Merge branch 'mm/maint-sort-config-doc' into mm/sort-config-doc
* mm/maint-sort-config-doc:
  config.txt: alphabetize configuration sections

Conflicts:
	Documentation/config.txt
2008-11-26 11:11:18 -08:00
Matt McCutchen
b0f34c3d67 config.txt: alphabetize configuration sections
I figured the sections might as well be in some order, so I chose alphabetical
but with "core" at the beginning.  This should help people add new variables
in the right places.

Signed-off-by: Matt McCutchen <matt@mattmccutchen.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-26 11:07:57 -08:00
Jim Meyering
c095a1db30 xdiff-interface.c: remove 10 duplicated lines
Remove an accidentally duplicated sequence of 10 lines.
This happens to plug a leak, too.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-26 10:47:41 -08:00
Marcel Koeppen
26d6cc555d t9129-git-svn-i18n-commitencoding: Make compare_svn_head_with() compatible with OSX sed
The sed call used in compare_svn_head_with() uses the + quantifier, which
is not supported in the OSX version of sed. It is replaced by the
equivalent \{1,\}.

Signed-off-by: Marcel Koeppen <git-dev@marzelpan.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-26 10:09:52 -08:00
Junio C Hamano
61af494ca4 Teach "git diff" to honour --[no-]ext-diff
The original intention of 72909be (Add diff-option --ext-diff, 2007-06-30)
was to optionally allow the use of external diff viewer in "git log"
family (while keeping them disabled by default).  It exposed the "allow
external diff" bit to the UI, but forgot to adjust the "git diff" codepath
that was set up to always allow use of the external diff viewer.

Noticed by Nazri Ramliy; tests by René Scharfe squashed in.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-26 09:58:41 -08:00
Trent Piepho
73c427eb99 send-email: Fix Pine address book parsing
See:  http://www.washington.edu/pine/tech-notes/low-level.html

Entries with a fcc or comment field after the address weren't parsed
correctly.

Continuation lines, identified by leading spaces, were also not handled.

Distribution lists which had ( ) around a list of addresses did not have
the parenthesis removed.

Signed-off-by: Trent Piepho <tpiepho@freescale.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-26 09:55:10 -08:00
Junio C Hamano
f20706220b Merge branch 'for-junio' of git://source.winehq.org/~julliard/git/git
* 'for-junio' of git://source.winehq.org/~julliard/git/git:
  git.el: Allow to commit even if there are no marked files.
  git.el: Add possibility to mark files directly in git-update-status-files.
  git.el: Add an insert file command.
  git.el: Never clear the status buffer, only update the files.
  git.el: Fix git-amend-commit to support amending an initial commit.
  git.el: Properly handle merge commits in git-amend-commit.
  git.el: Simplify handling of merge heads in the commit log-edit buffer.
  git.el: Remove the env parameter in git-call-process and git-call-process-string.
  git.el: Improve error handling for commits.
2008-11-25 21:52:28 -08:00
Christian Couder
ee2314f59a bisect: teach "skip" to accept special arguments like "A..B"
The current "git bisect skip" syntax is "git bisect skip [<rev>...]"
so it's already possible to skip a range of revisions using
something like:

$ git bisect skip $(git rev-list A..B)

where A and B are the bounds of the range we want to skip.

This patch teaches "git bisect skip" to accept:

$ git bisect skip A..B

as an abbreviation for the former command.

This is done by checking each argument to see if it contains two
dots one after the other ('..'), and by expending it using
"git rev-list" if that is the case.

Note that this patch will not make "git bisect skip" accept all
that "git rev-list" accepts, as things like "^A B" for exemple
will not work. But things like "A B..C D E F.. ..G H...I" should
work as expected.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25 21:51:05 -08:00
Miklos Vajna
b5ff37ac6b builtin_clone: use strbuf in cmd_clone()
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25 15:34:26 -08:00
Miklos Vajna
b9e125e07e builtin-clone: use strbuf in clone_local() and copy_or_link_directory()
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25 15:34:25 -08:00
Miklos Vajna
32716a2c6c builtin-clone: use strbuf in guess_dir_name()
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-25 15:34:25 -08:00
Junio C Hamano
ef3b38b445 Merge branch 'maint'
* maint:
  Fix misleading wording for git-cherry-pick
2008-11-23 20:36:54 -08:00
René Scharfe
7de1950cb2 remove the unused files interpolate.c and interpolate.h
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2008-11-23 19:56:57 -08:00