This project is mirrored from https://github.com/git/git. Updated .
  1. 31 Mar, 2014 1 commit
  2. 03 Mar, 2014 1 commit
  3. 25 Oct, 2013 1 commit
  4. 04 Sep, 2013 1 commit
    • Johannes Sixt's avatar
      add--interactive: fix external command invocation on Windows · df17e77c
      Johannes Sixt authored
      Back in 21e9757e (Hack git-add--interactive to make it work with
      ActiveState Perl, 2007-08-01), the invocation of external commands was
      changed to use qx{} on Windows. The rationale was that the command
      interpreter on Windows is not a POSIX shell, but rather Windows's CMD.
      That patch was wrong to include 'msys' in the check whether to use qx{}
      or not: 'msys' identifies MSYS perl as shipped with Git for Windows,
      which does not need the special treatment; qx{} should be used only with
      ActiveState perl, which is identified by 'MSWin32'.
      Signed-off-by: default avatarJohannes Sixt <j6t@kdbg.org>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      df17e77c
  5. 23 Jun, 2013 1 commit
    • Junio C Hamano's avatar
      add -i: add extra options at the right place in "diff" command line · e5c29097
      Junio C Hamano authored
      Appending "--diff-algorithm=histogram" at the end of canned command
      line for various modes of "diff" is correct for most of them but not
      for "stash" that has a non-option already wired in, like so:
      
      	'stash' => {
      		DIFF => 'diff-index -p HEAD',
      
      Appending an extra option after non-option may happen to work due to
      overly lax command line parser, but that is not something we should
      rely on.  Instead, splice in the extra argument immediately after the
      command name (i.e. 'diff-index', 'diff-files', etc.).
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      e5c29097
  6. 12 Jun, 2013 1 commit
    • John Keeping's avatar
      add--interactive: respect diff.algorithm · 2cc0f53b
      John Keeping authored
      When staging hunks interactively it is sometimes useful to use an
      alternative diff algorithm which splits the changes into hunks in a more
      logical manner.  This is not possible because the plumbing commands
      called by add--interactive ignore the "diff.algorithm" configuration
      option (as they should).
      
      Since add--interactive is a porcelain command it should respect this
      configuration variable.  To do this, make it read diff.algorithm and
      pass its value to the underlying diff-index and diff-files invocations.
      
      At this point, do not add options to "git add", "git reset" or "git
      checkout" (all of which can call git-add--interactive).  If a user
      wants to override the value on the command line they can use:
      
      	git -c diff.algorithm=$ALGO ...
      Signed-off-by: John Keeping's avatarJohn Keeping <john@keeping.me.uk>
      Reviewed-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      2cc0f53b
  7. 12 Apr, 2013 1 commit
  8. 25 Jun, 2012 1 commit
  9. 05 Apr, 2012 1 commit
    • Jeff King's avatar
      add--interactive: ignore unmerged entries in patch mode · 4066bd67
      Jeff King authored
      When "add -p" sees an unmerged entry, it shows the combined
      diff and then immediately skips the hunk. This can be
      confusing in a variety of ways, depending on whether there
      are other changes to stage (in which case you get the
      superfluous combined diff output in between other hunks) or
      not (in which case you get the combined diff and the program
      exits immediately, rather than seeing "No changes").
      
      The current behavior was not planned, and is just what the
      implementation happens to do. Instead, let's explicitly
      remove unmerged entries from our list of modified files, and
      print a warning that we are ignoring them.
      
      We can cheaply find which entries are unmerged by adding
      "--raw" output to the "diff-files --numstat" we already run.
      There is one non-obvious thing we must change when parsing
      this combined output. Before this patch, when we saw a
      numstat line for a file that did not have index changes, we
      would create a new record with 'unchanged' in the 'INDEX'
      field.  Because "--raw" comes before "--numstat", we must
      move this special-case down to the raw-line case (and it is
      sufficient to move it rather than handle it in both places,
      since any file which has a --numstat will also have a --raw
      entry).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      4066bd67
  10. 18 May, 2011 1 commit
    • Thomas Rast's avatar
      add -i: ignore terminal escape sequences · b5cc0032
      Thomas Rast authored
      On the author's terminal, the up-arrow input sequence is ^[[A, and
      thus fat-fingering an up-arrow into 'git checkout -p' is quite
      dangerous: git-add--interactive.perl will ignore the ^[ and [
      characters and happily treat A as "discard everything".
      
      As a band-aid fix, use Term::Cap to get all terminal capabilities.
      Then use the heuristic that any capability value that starts with ^[
      (i.e., \e in perl) must be a key input sequence.  Finally, given an
      input that starts with ^[, read more characters until we have read a
      full escape sequence, then return that to the caller.  We use a
      timeout of 0.5 seconds on the subsequent reads to avoid getting stuck
      if the user actually input a lone ^[.
      
      Since none of the currently recognized keys start with ^[, the net
      result is that the sequence as a whole will be ignored and the help
      displayed.
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      b5cc0032
  11. 29 Apr, 2011 3 commits
    • Junio C Hamano's avatar
      "add -p": work-around an old laziness that does not coalesce hunks · 933e44d3
      Junio C Hamano authored
      Since 0beee4c6 (git-add--interactive: remove hunk coalescing, 2008-07-02),
      "git add--interactive" behaves lazily and passes overlapping hunks to the
      underlying "git apply" without coalescing.  This was partially corrected
      by 7a26e653 (its partial revert, 2009-05-16), but overlapping hunks are
      still passed when the patch is edited.
      
      Teach "git apply" the --allow-overlap option that disables a safety
      feature that avoids misapplication of patches by not applying patches
      to overlapping hunks, and pass this option form "add -p" codepath.
      
      Do not even advertise the option, as this is merely a workaround, and the
      correct fix is to make "add -p" correctly coalesce adjacent patch hunks.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      933e44d3
    • Junio C Hamano's avatar
      add--interactive.perl: factor out repeated --recount option · 9dce8323
      Junio C Hamano authored
      Depending on the direction and the target of patch application, we would
      need to pass --cached and --reverse to underlying "git apply".  Also we
      only pass --check when we are not applying but just checking.
      
      But we always pass --recount since 8cbd4310 (git-add--interactive: replace
      hunk recounting with apply --recount, 2008-07-02).  Instead of repeating
      the same --recount over and over again, move it to a single place that
      actually runs the command, namely, "run_git_apply" subroutine.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      9dce8323
    • Junio C Hamano's avatar
      add -p: 'q' should really quit · f5ea3f2b
      Junio C Hamano authored
      The "quit" command was added in 9a7a1e03 (git add -p: new "quit" command at
      the prompt, 2009-04-10) to allow the user to say that hunks other than
      what have already been chosen are undesirable, and exit the interactive
      loop immediately.  It forgot that there may be an undecided hunk before
      the current one.  In such a case, the interactive loop still goes back to
      the beginning.
      
      Clear all the USE bit for undecided hunks and exit the loop.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      f5ea3f2b
  12. 28 Oct, 2010 1 commit
  13. 27 Sep, 2010 2 commits
    • Ævar Arnfjörð Bjarmason's avatar
      perl: use "use warnings" instead of -w · 3328aced
      Ævar Arnfjörð Bjarmason authored
      Change the Perl scripts to turn on lexical warnings instead of setting
      the global $^W variable via the -w switch.
      
      The -w sets warnings for all code that interpreter runs, while "use
      warnings" is lexically scoped. The former is probably not what the
      authors wanted.
      
      As an auxiliary benefit it's now possible to build Git with:
      
          PERL_PATH='/usr/bin/env perl'
      
      Which would previously result in failures, since "#!/usr/bin/env perl -w"
      doesn't work as a shebang.
      Signed-off-by: Ævar Arnfjörð Bjarmason's avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      3328aced
    • Ævar Arnfjörð Bjarmason's avatar
      perl: bump the required Perl version to 5.8 from 5.6.[21] · d48b2841
      Ævar Arnfjörð Bjarmason authored
      Formalize our dependency on perl 5.8, bumped from 5.6.[12]. We already
      used the three-arg form of open() which was introduced in 5.6.1, but
      t/t9700/test.pl explicitly depended on 5.6.2.
      
      However git-add--interactive.pl has been failing on the 5.6 line since
      it was introduced in v1.5.0-rc0~12^2~2 back in 2006 due to this open
      syntax:
      
          sub run_cmd_pipe {
                 my $fh = undef;
                 open($fh, '-|', @_) or die;
                 return <$fh>;
          }
      
      Which when executed dies on "Can't use an undefined value as
      filehandle reference". Several of our tests also fail on 5.6 (even
      more when compiled with NO_PERL_MAKEMAKER=1):
      
          t2016-checkout-patch.sh
          t3904-stash-patch.sh
          t3701-add-interactive.sh
          t7105-reset-patch.sh
          t7501-commit.sh
          t9700-perl-git.sh
      
      Our code is bitrotting on 5.6 with no-one interested in fixing it, and
      pinning us to such an ancient release of Perl is keeping us from using
      useful features introduced in the 5.8 release.
      
      The 5.6 series is now over 10 years old, and the 5.6.2 maintenance
      release almost 7. 5.8 on the other hand is more than 8 years old.
      
      All the modern Unix-like operating systems have now upgraded to it or
      a later version, and 5.8 packages are available for old IRIX, AIX
      Solaris and Tru64 systems.
      Signed-off-by: Ævar Arnfjörð Bjarmason's avatarÆvar Arnfjörð Bjarmason <avarab@gmail.com>
      Acked-by: default avatarTor Arntsen <tor@spacetec.no>
      Acked-by: default avatarRandal L. Schwartz <merlyn@stonehenge.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      d48b2841
  14. 13 Jun, 2010 1 commit
  15. 23 Feb, 2010 1 commit
    • Jeff King's avatar
      add-interactive: fix bogus diff header line ordering · e1327ed5
      Jeff King authored
      When we look at a patch for adding hunks interactively, we
      first split it into a header and a list of hunks. Some of
      the header lines, such as mode changes and deletion, however,
      become their own selectable hunks. Later when we reassemble
      the patch, we simply concatenate the header and the selected
      hunks. This leads to patches like this:
      
        diff --git a/file b/file
        index d95f3ad..0000000
        --- a/file
        +++ /dev/null
        deleted file mode 100644
        @@ -1 +0,0 @@
        -content
      
      Notice how the deletion comes _after_ the ---/+++ lines,
      when it should come before.
      
      In many cases, we can get away with this as git-apply
      accepts the slightly bogus input. However, in the specific
      case of a deletion line that is being applied via "apply
      -R", this malformed patch triggers an assert in git-apply.
      This comes up when discarding a deletion via "git checkout
      -p".
      
      Rather than try to make git-apply accept our odd input,
      let's just reassemble the patch in the correct order.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      e1327ed5
  16. 08 Dec, 2009 1 commit
    • Jeff King's avatar
      add-interactive: fix deletion of non-empty files · 8947fdd5
      Jeff King authored
      Commit 24ab81ae fixed the deletion of empty files, but broke
      deletion of non-empty files. The approach it took was to
      factor out the "deleted" line from the patch header into its
      own hunk, the same way we do for mode changes. However,
      unlike mode changes, we only showed the special "delete this
      file" hunk if there were no other hunks. Otherwise, the user
      would annoyingly be presented with _two_ hunks: one for
      deleting the file and one for deleting the content.
      
      This meant that in the non-empty case, we forgot about the
      deleted line entirely, and we submitted a bogus patch to
      git-apply (with "/dev/null" as the destination file, but not
      marked as a deletion).
      
      Instead, this patch combines the file deletion hunk and the
      content deletion hunk (if there is one) into a single
      deletion hunk which is either staged or not.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      8947fdd5
  17. 13 Nov, 2009 1 commit
  18. 28 Oct, 2009 1 commit
    • Jeff King's avatar
      add-interactive: handle deletion of empty files · 24ab81ae
      Jeff King authored
      Usually we show deletion as a big hunk deleting all of the
      file's text. However, for files with no content, the diff
      shows just the 'deleted file mode ...' line. This patch
      cause "add -p" (and related commands) to recognize that line
      and explicitly ask about deleting the file.
      
      We only add the "stage this deletion" hunk for empty files,
      since other files will already ask about the big content
      deletion hunk. We could also change those files to simply
      display "stage this deletion", but showing the actual
      deleted content is probably what an interactive user wants.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      24ab81ae
  19. 10 Oct, 2009 1 commit
  20. 15 Aug, 2009 4 commits
    • Thomas Rast's avatar
      Implement 'git stash save --patch' · dda1f2a5
      Thomas Rast authored
      This adds a hunk-based mode to git-stash.  You can select hunks from
      the difference between HEAD and worktree, and git-stash will build a
      stash that reflects these changes.  The index state of the stash is
      the same as your current index, and we also let --patch imply
      --keep-index.
      
      Note that because the selected hunks are rolled back from the worktree
      but not the index, the resulting state may appear somewhat confusing
      if you had also staged these changes.  This is not entirely
      satisfactory, but due to the way stashes are applied, other solutions
      would require a change to the stash format.
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      dda1f2a5
    • Thomas Rast's avatar
      Implement 'git checkout --patch' · 4f353658
      Thomas Rast authored
      This introduces a --patch mode for git-checkout.  In the index usage
      
        git checkout --patch -- [files...]
      
      it lets the user discard edits from the <files> at the granularity of
      hunks (by selecting hunks from 'git diff' and then reverse applying
      them to the worktree).
      
      We also accept a revision argument.  In the case
      
        git checkout --patch HEAD -- [files...]
      
      we offer hunks from the difference between HEAD and the worktree, and
      reverse applies them to both index and worktree, allowing you to
      discard staged changes completely.  In the non-HEAD usage
      
        git checkout --patch <revision> -- [files...]
      
      it offers hunks from the difference between the worktree and
      <revision>.  The chosen hunks are then applied to both index and
      worktree.
      
      The application to worktree and index is done "atomically" in the
      sense that we first check if the patch applies to the index (it should
      always apply to the worktree).  If it does not, we give the user a
      choice to either abort or apply to the worktree anyway.
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      4f353658
    • Thomas Rast's avatar
      Implement 'git reset --patch' · d002ef4d
      Thomas Rast authored
      This introduces a --patch mode for git-reset.  The basic case is
      
        git reset --patch -- [files...]
      
      which acts as the opposite of 'git add --patch -- [files...]': it
      offers hunks for *un*staging.  Advanced usage is
      
        git reset --patch <revision> -- [files...]
      
      which offers hunks from the diff between the index and <revision> for
      forward application to the index.  (That is, the basic case is just
      <revision> = HEAD.)
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      d002ef4d
    • Thomas Rast's avatar
      add -p: do not attempt to coalesce mode changes · 3d792161
      Thomas Rast authored
      In 0392513f (add-interactive: refactor mode hunk handling, 2009-04-16),
      we merged the interaction loops for mode changes and hunk staging.
      This was fine at the time, because 0beee4c6 (git-add--interactive:
      remove hunk coalescing, 2008-07-02) removed hunk coalescing.
      
      However, in 7a26e653 (Revert "git-add--interactive: remove hunk
      coalescing", 2009-05-16), we resurrected it.  Since then, the code
      would attempt in vain to merge mode changes with diff hunks,
      corrupting both in the process.
      
      We add a check to the coalescing loop to ensure it only looks at diff
      hunks, thus skipping mode changes.
      Noticed-by: default avatarKirill Smelkov <kirr@mns.spb.ru>
      Signed-off-by: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      3d792161
  21. 14 Aug, 2009 1 commit
  22. 03 Jun, 2009 1 commit
  23. 17 May, 2009 1 commit
  24. 20 Apr, 2009 1 commit
  25. 19 Apr, 2009 2 commits
    • Jeff King's avatar
      add-interactive: refactor mode hunk handling · 7535e5a1
      Jeff King authored
      The original implementation considered the mode separately
      from the rest of the hunks, asking about it outside the main
      hunk-selection loop. This patch instead places a mode change
      as the first hunk in the loop. This has two advantages:
      
        1. less duplicated code (since we use the main selection
           loop). This also cleans up an inconsistency, which is
           that the main selection loop separates options with a
           comma, whereas the mode prompt used slashes.
      
        2. users can now skip the mode change and come back to it,
           search for it (via "/mode"), etc, as they can with other
           hunks.
      
      To facilitate this, each hunk is now marked with a "type".
      Mode hunks are not considered for splitting (which would
      make no sense, and also confuses the split_hunk function),
      nor are they editable. In theory, one could edit the mode
      lines and change to a new mode. In practice, there are only
      two modes that git cares about (0644 and 0755), so either
      you want to move from one to the other or not (and you can
      do that by staging or not staging).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      7535e5a1
    • Matthieu Moy's avatar
      git add -p: new "quit" command at the prompt. · cbd3a01e
      Matthieu Moy authored
      There's already 'd' to stop staging hunks in a file, but no explicit
      command to stop the interactive staging (for the current files and the
      remaining ones).  Of course you can do 'd' and then ^C, but it would be
      more intuitive to allow 'quit' action.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      cbd3a01e
  26. 16 Apr, 2009 2 commits
    • Jeff King's avatar
      add-interactive: refactor mode hunk handling · 0392513f
      Jeff King authored
      The original implementation considered the mode separately
      from the rest of the hunks, asking about it outside the main
      hunk-selection loop. This patch instead places a mode change
      as the first hunk in the loop. This has two advantages:
      
        1. less duplicated code (since we use the main selection
           loop). This also cleans up an inconsistency, which is
           that the main selection loop separates options with a
           comma, whereas the mode prompt used slashes.
      
        2. users can now skip the mode change and come back to it,
           search for it (via "/mode"), etc, as they can with other
           hunks.
      
      To facilitate this, each hunk is now marked with a "type".
      Mode hunks are not considered for splitting (which would
      make no sense, and also confuses the split_hunk function),
      nor are they editable. In theory, one could edit the mode
      lines and change to a new mode. In practice, there are only
      two modes that git cares about (0644 and 0755), so either
      you want to move from one to the other or not (and you can
      do that by staging or not staging).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      0392513f
    • Matthieu Moy's avatar
      git add -p: new "quit" command at the prompt. · 9a7a1e03
      Matthieu Moy authored
      There's already 'd' to stop staging hunks in a file, but no explicit
      command to stop the interactive staging (for the current files and the
      remaining ones).  Of course you can do 'd' and then ^C, but it would be
      more intuitive to allow 'quit' action.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      9a7a1e03
  27. 18 Feb, 2009 1 commit
  28. 12 Feb, 2009 1 commit
  29. 08 Feb, 2009 1 commit
    • Stephan Beyer's avatar
      add -p: get rid of Git.pm warnings about unitialized values · 9aad6cba
      Stephan Beyer authored
      After invoking git add -p I always got the warnings:
      
       Use of uninitialized value $_[3] in exec at Git.pm line 1282.
       Use of uninitialized value $args[2] in join or string at Git.pm line 1264.
      
      A bisect showed that these warnings occur in a3019736 "add -p: print errors
      in separate color" the first time.
      
      They can be reproduced by setting color.ui (or color.interactive) to "auto"
      and unsetting color.interactive.help and color.interactive.error.
      I am using Perl 5.10.0.
      
      The reason of the warning is that color.interactive.error defaults to
      color.interactive.help which defaults to nothing in the specific codepath.
      It defaults to 'red bold' some lines above which could lead to the wrong
      assumption that it always defaults to 'red bold' now.
      
      This patch lets it default to 'red bold', blowing the warnings away.
      Signed-off-by: default avatarStephan Beyer <s-beyer@gmx.net>
      Acked-By: default avatarThomas Rast <trast@student.ethz.ch>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
      9aad6cba
  30. 07 Feb, 2009 1 commit
  31. 06 Feb, 2009 2 commits