1. 10 8月, 2017 1 次提交
  2. 03 8月, 2017 1 次提交
    • B
      add, reset: ensure submodules can be added or reset · 55568086
      Brandon Williams 提交于
      Commit aee9c7d6 (Submodules: Add the new "ignore" config option for
      diff and status) introduced the ignore configuration option for
      submodules so that configured submodules could be omitted from the
      status and diff commands.  Because this flag is respected in the diff
      machinery it has the unintended consequence of potentially prohibiting
      users from adding or resetting a submodule, even when a path to the
      submodule is explicitly given.
      
      Ensure that submodules can be added or set, even if they are configured
      to be ignored, by setting the `DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG` diff
      flag.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      55568086
  3. 16 6月, 2017 2 次提交
    • B
      config: don't include config.h by default · b2141fc1
      Brandon Williams 提交于
      Stop including config.h by default in cache.h.  Instead only include
      config.h in those files which require use of the config system.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      b2141fc1
    • J
      add: warn when adding an embedded repository · 53213994
      Jeff King 提交于
      It's an easy mistake to add a repository inside another
      repository, like:
      
        git clone $url
        git add .
      
      The resulting entry is a gitlink, but there's no matching
      .gitmodules entry. Trying to use "submodule init" (or clone
      with --recursive) doesn't do anything useful. Prior to
      v2.13, such an entry caused git-submodule to barf entirely.
      In v2.13, the entry is considered "inactive" and quietly
      ignored. Either way, no clone of your repository can do
      anything useful with the gitlink without the user manually
      adding the submodule config.
      
      In most cases, the user probably meant to either add a real
      submodule, or they forgot to put the embedded repository in
      their .gitignore file.
      
      Let's issue a warning when we see this case. There are a few
      things to note:
      
        - the warning will go in the git-add porcelain; anybody
          wanting to do low-level manipulation of the index is
          welcome to create whatever funny states they want.
      
        - we detect the case by looking for a newly added gitlink;
          updates via "git add submodule" are perfectly reasonable,
          and this avoids us having to investigate .gitmodules
          entirely
      
        - there's a command-line option to suppress the warning.
          This is needed for git-submodule itself (which adds the
          entry before adding any submodule config), but also
          provides a mechanism for other scripts doing
          submodule-like things.
      
      We could make this a hard error instead of a warning.
      However, we do add lots of sub-repos in our test suite. It's
      not _wrong_ to do so. It just creates a state where users
      may be surprised. Pointing them in the right direction with
      a gentle hint is probably the best option.
      
      There is a config knob that can disable the (long) hint. But
      I intentionally omitted a config knob to disable the warning
      entirely. Whether the warning is sensible or not is
      generally about context, not about the user's preferences.
      If there's a tool or workflow that adds gitlinks without
      matching .gitmodules, it should probably be taught about the
      new command-line option, rather than blanket-disabling the
      warning.
      Signed-off-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      53213994
  4. 12 5月, 2017 2 次提交
  5. 10 5月, 2017 1 次提交
    • B
      submodule: add die_in_unpopulated_submodule function · bdab9721
      Brandon Williams 提交于
      Currently 'git add' is the only command which dies when launched from an
      unpopulated submodule (the place-holder directory for a submodule which
      hasn't been checked out).  This is triggered implicitly by passing the
      PATHSPEC_STRIP_SUBMODULE_SLASH_EXPENSIVE flag to 'parse_pathspec()'.
      
      Instead make this desire more explicit by creating a function
      'die_in_unpopulated_submodule()' which dies if the provided 'prefix' has
      a leading path component which matches a submodule in the the index.
      Signed-off-by: NBrandon Williams <bmwill@google.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      bdab9721
  6. 06 5月, 2017 3 次提交
  7. 08 12月, 2016 1 次提交
    • J
      hold_locked_index(): align error handling with hold_lockfile_for_update() · b3e83cc7
      Junio C Hamano 提交于
      Callers of the hold_locked_index() function pass 0 when they want to
      prepare to write a new version of the index file without wishing to
      die or emit an error message when the request fails (e.g. somebody
      else already held the lock), and pass 1 when they want the call to
      die upon failure.
      
      This option is called LOCK_DIE_ON_ERROR by the underlying lockfile
      API, and the hold_locked_index() function translates the paramter to
      LOCK_DIE_ON_ERROR when calling the hold_lock_file_for_update().
      
      Replace these hardcoded '1' with LOCK_DIE_ON_ERROR and stop
      translating.  Callers other than the ones that are replaced with
      this change pass '0' to the function; no behaviour change is
      intended with this patch.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      ---
      
      Among the callers of hold_locked_index() that passes 0:
      
       - diff.c::refresh_index_quietly() at the end of "git diff" is an
         opportunistic update; it leaks the lockfile structure but it is
         just before the program exits and nobody should care.
      
       - builtin/describe.c::cmd_describe(),
         builtin/commit.c::cmd_status(),
         sequencer.c::read_and_refresh_cache() are all opportunistic
         updates and they are OK.
      
       - builtin/update-index.c::cmd_update_index() takes a lock upfront
         but we may end up not needing to update the index (i.e. the
         entries may be fully up-to-date), in which case we do not need to
         issue an error upon failure to acquire the lock.  We do diagnose
         and die if we indeed need to update, so it is OK.
      
       - wt-status.c::require_clean_work_tree() IS BUGGY.  It asks
         silence, does not check the returned value.  Compare with
         callsites like cmd_describe() and cmd_status() to notice that it
         is wrong to call update_index_if_able() unconditionally.
      b3e83cc7
  8. 16 9月, 2016 1 次提交
  9. 08 6月, 2016 1 次提交
    • E
      add: add --chmod=+x / --chmod=-x options · 4e55ed32
      Edward Thomson 提交于
      The executable bit will not be detected (and therefore will not be
      set) for paths in a repository with `core.filemode` set to false,
      though the users may still wish to add files as executable for
      compatibility with other users who _do_ have `core.filemode`
      functionality.  For example, Windows users adding shell scripts may
      wish to add them as executable for compatibility with users on
      non-Windows.
      
      Although this can be done with a plumbing command
      (`git update-index --add --chmod=+x foo`), teaching the `git-add`
      command allows users to set a file executable with a command that
      they're already familiar with.
      Signed-off-by: NEdward Thomson <ethomson@edwardthomson.com>
      Helped-by: NJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      4e55ed32
  10. 25 10月, 2015 1 次提交
    • J
      add: simplify -u/-A without pathspec · 29abb339
      Junio C Hamano 提交于
      Since Git 2.0, "add -u" and "add -A" run from a subdirectory without
      any pathspec mean "everything in the working tree" (before 2.0, they
      were limited to the current directory).  The limiting to the current
      directory was implemented by inserting "." to the command line when
      the end user did not give us any pathspec.  At 2.0, we updated the
      code to insert ":/" (instead of '.') to consider everything from the
      top-level, by using a pathspec magic "top".
      
      The call to parse_pathspec() using the command line arguments is,
      however, made with PATHSPEC_PREFER_FULL option since 5a76aff1 (add:
      convert to use parse_pathspec, 2013-07-14), which predates Git 2.0.
      In retrospect, there was no need to turn "adding . to limit to the
      directory" into "adding :/ to unlimit to everywhere" in Git 2.0;
      instead we could just have done "if there is no pathspec on the
      command line, just let it be".  The parse_pathspec() then would give
      us a pathspec that matches everything and all is well.
      
      Incidentally such a simplification also fixes a corner case bug that
      stems from the fact that ":/" does not necessarily mean any magic.
      A user would say "git --literal-pathspecs add -u :/" from the
      command line when she has a directory ':' and wants to add
      everything in it (and she knows that her :/ will be taken as
      'everything under the sun' magic pathspec unless she disables the
      magic with --literal-pathspecs).  The internal use of ':/' would
      behave the same way as such an explicitly given ":/" when run with
      "--literal-pathspecs", and will not add everything under the sun as
      the code originally intended.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      29abb339
  11. 31 7月, 2015 1 次提交
  12. 24 6月, 2015 1 次提交
    • J
      Revert "diff-lib.c: adjust position of i-t-a entries in diff" · 78cc1a54
      Junio C Hamano 提交于
      This reverts commit d95d728a.
      
      It turns out that many other commands that need to interact with the
      result of running diff-files and diff-index, e.g.  "git apply", "git
      rm", etc., need to be adjusted to the new world order it brings in.
      For example, it would break this sequence to correct a whitespace
      breakage in the parts you changed:
      
      	git add -N file
      	git diff --cached file | git apply --cached --whitespace=fix
      	git checkout file
      
      In the old world order, "diff" showed a patch to modify an existing
      empty file by adding its full contents, and "apply" updated the
      index by modifying the existing empty blob (which is what an
      Intent-to-Add entry records in the index) with that patch.
      
      In the new world order, "diff" shows a patch to create a new file
      with its full contents, but because "apply" thinks that the i-t-a
      entry already exists in the index, it refused to accept a creation.
      
      Adjusting "apply" to this new world order is easy, but we need to
      assess the extent of the damage to the rest of the system the new
      world order brought in before going forward and adjust them all,
      after which we can resurrect the commit being reverted here.
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      78cc1a54
  13. 13 5月, 2015 1 次提交
  14. 24 3月, 2015 1 次提交
    • N
      diff-lib.c: adjust position of i-t-a entries in diff · d95d728a
      Nguyễn Thái Ngọc Duy 提交于
      Entries added by "git add -N" are reminder for the user so that they
      don't forget to add them before committing. These entries appear in
      the index even though they are not real. Their presence in the index
      leads to a confusing "git status" like this:
      
          On branch master
          Changes to be committed:
                  new file:   foo
      
          Changes not staged for commit:
                  modified:   foo
      
      If you do a "git commit", "foo" will not be included even though
      "status" reports it as "to be committed". This patch changes the
      output to become
      
          On branch master
          Changes not staged for commit:
                  new file:   foo
      
          no changes added to commit
      
      The two hunks in diff-lib.c adjust "diff-index" and "diff-files" so
      that i-t-a entries appear as new files in diff-files and nothing in
      diff-index.
      
      Due to this change, diff-files may start to report "new files" for the
      first time. "add -u" needs to be told about this or it will die in
      denial, screaming "new files can't exist! Reality is wrong." Luckily,
      it's the only one among run_diff_files() callers that needs fixing.
      
      Now in the new world order, a hierarchy in the index that contain
      i-t-a paths is written out as a tree object as if these i-t-a
      entries do not exist, and comparing the index with such a tree
      object that would result from writing out the hierarchy will result
      in no difference.  Update a test in t2203 that expected the i-t-a
      entries to appear as "added to the index" in the comparison to
      instead expect no output.
      
      An earlier change eec3e7e4 (cache-tree: invalidate i-t-a paths after
      generating trees, 2012-12-16) becomes an unnecessary pessimization
      in the new world order---a cache-tree in the index that corresponds
      to a hierarchy with i-t-a paths can now be marked as valid and
      record the object name of the tree that results from writing a tree
      object out of that hierarchy, as it will compare equal to that tree.
      
      Reverting the commit is left for the future, though, as it is purely
      a performance issue and no longer affects correctness.
      Helped-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Helped-by: NJunio C Hamano <gitster@pobox.com>
      Signed-off-by: NNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      d95d728a
  15. 15 1月, 2015 1 次提交
  16. 22 11月, 2014 1 次提交
    • M
      add: ignore only ignored files · 1d31e5a2
      Michael J Gruber 提交于
      "git add foo bar" adds neither foo nor bar when bar is ignored, but dies
      to let the user recheck their command invocation. This becomes less
      helpful when "git add foo.*" is subject to shell expansion and some of
      the expanded files are ignored.
      
      "git add --ignore-errors" is supposed to ignore errors when indexing
      some files and adds the others. It does ignore errors from actual
      indexing attempts, but does not ignore the error "file is ignored" as
      outlined above. This is unexpected.
      
      Change "git add foo bar" to add foo when bar is ignored, but issue
      a warning and return a failure code as before the change.
      
      That is, in the case of trying to add ignored files we now act the same
      way (with or without "--ignore-errors") in which we act for more
      severe indexing errors when "--ignore-errors" is specified.
      Signed-off-by: NMichael J Gruber <git@drmicha.warpmail.net>
      Reviewed-by: NJeff King <peff@peff.net>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      1d31e5a2
  17. 02 10月, 2014 1 次提交
  18. 21 8月, 2014 1 次提交
  19. 14 6月, 2014 1 次提交
  20. 19 3月, 2014 1 次提交
  21. 25 2月, 2014 1 次提交
  22. 27 12月, 2013 1 次提交
  23. 07 12月, 2013 1 次提交
  24. 06 9月, 2013 1 次提交
  25. 31 8月, 2013 1 次提交
  26. 20 7月, 2013 1 次提交
  27. 16 7月, 2013 9 次提交
  28. 27 4月, 2013 1 次提交