1. 09 Oct, 2018 2 commits
  2. 13 Aug, 2018 1 commit
  3. 06 Aug, 2018 1 commit
    • yohoho hahhahah's avatar
      rebase: start implementing it as a builtin · 55071ea2
      yohoho hahhahah authored
      This commit imitates the strategy that was used to convert the
      difftool to a builtin. We start by renaming the shell script
      `git-rebase.sh` to `git-legacy-rebase.sh` and introduce a
      `builtin/rebase.c` that simply executes the shell script version,
      unless the config setting `rebase.useBuiltin` is set to `true`.
      The motivation behind this is to rewrite all the functionality of the
      shell script version in the aforementioned `rebase.c`, one by one and
      be able to conveniently test new features by configuring
      In the original difftool conversion, if sane_execvp() that attempts to
      run the legacy scripted version returned with non-negative status, the
      command silently exited without doing anything with success, but
      sane_execvp() should not return with non-negative status in the first
      place, so we use die() to notice such an abnormal case.
      We intentionally avoid reading the config directly to avoid
      messing up the GIT_* environment variables when we need to fall back to
      exec()ing the shell script. The test of builtin rebase can be done by
      `git -c rebase.useBuiltin=true rebase ...`
      Signed-off-by: yohoho hahhahah's avatarPratik Karki <predatoramigo@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  4. 20 Jul, 2018 1 commit
  5. 28 May, 2018 1 commit
    • Jeff King's avatar
      make show-index a builtin · ff417260
      Jeff King authored
      The git-show-index command is built as its own separate
      program. There's really no good reason for this, and it
      means we waste extra space on disk (and CPU time running the
      linker). Let's fold it in to the main binary as a builtin.
      The history here is actually a bit amusing. The program
      itself is mostly self-contained, and doesn't even use our
      normal pack index code. In a5031214 (slim down "git
      show-index", 2010-01-21), we even stopped using xmalloc() so
      that it could avoid libgit.a entirely. But then 040a6551
      (cleanup: use internal memory allocation wrapper functions
      everywhere, 2011-10-06) switched that back to xmalloc, which
      later become ALLOC_ARRAY().
      Making it a builtin should give us the best of both worlds:
      no wasted space and no need to avoid the usual patterns.
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  6. 02 Apr, 2018 1 commit
  7. 15 Mar, 2018 1 commit
    • Brandon Williams's avatar
      serve: introduce git-serve · ed10cb95
      Brandon Williams authored
      Introduce git-serve, the base server for protocol version 2.
      Protocol version 2 is intended to be a replacement for Git's current
      wire protocol.  The intention is that it will be a simpler, less
      wasteful protocol which can evolve over time.
      Protocol version 2 improves upon version 1 by eliminating the initial
      ref advertisement.  In its place a server will export a list of
      capabilities and commands which it supports in a capability
      advertisement.  A client can then request that a particular command be
      executed by providing a number of capabilities and command specific
      parameters.  At the completion of a command, a client can request that
      another command be executed or can terminate the connection by sending a
      flush packet.
      Signed-off-by: default avatarBrandon Williams <bmwill@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  8. 14 Mar, 2018 1 commit
  9. 03 Aug, 2017 3 commits
    • Martin Ågren's avatar
      git.c: provide setup_auto_pager() · 033fe3d9
      Martin Ågren authored
      The previous patch introduced a way for builtins to declare that they
      will take responsibility for handling the `pager.foo`-config item. (See
      the commit message of that patch for why that could be useful.)
      Provide setup_auto_pager(), which builtins can call in order to handle
      `pager.<cmd>`, including possibly starting the pager. Make this function
      don't do anything if a pager has already been started, as indicated by
      use_pager or pager_in_use().
      Whenever this function is called from a builtin, git.c will already have
      called commit_pager_choice(). Since commit_pager_choice() treats the
      special value -1 as "punt" or "not yet decided", it is not a problem
      that we might end up calling commit_pager_choice() once in git.c and
      once (or more) in the builtin. Make the new function use -1 in the same
      way and document it as "punt".
      Don't add any users of setup_auto_pager just yet, one will follow in
      a later patch.
      Suggested-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Martin Ågren's avatar
      git.c: let builtins opt for handling `pager.foo` themselves · c409824c
      Martin Ågren authored
      Before launching a builtin git foo and unless mechanisms with precedence
      are in use, we check for and handle the `pager.foo` config. This is done
      without considering exactly how git foo is being used, and indeed, git.c
      cannot (and should not) know what the arguments to git foo are supposed
      to achieve.
      In practice this means that, e.g., `git -c pager.tag tag -a new-tag`
      results in errors such as "Vim: Warning: Output is not to a terminal"
      and a garbled terminal. Someone who makes use of both `git tag -a` and
      `git tag -l` will probably not set `pager.tag`, so that `git tag -a`
      will actually work, at the cost of not paging output of `git tag -l`.
      To allow individual builtins to make more informed decisions about when
      to respect `pager.foo`, introduce a flag DELAY_PAGER_CONFIG. If the flag
      is set, do not check `pager.foo`.
      Do not check for DELAY_PAGER_CONFIG in `execv_dashed_external()`. That
      call site is arguably wrong, although in a way that is not yet visible,
      and will be changed in a slightly different direction in a later patch.
      Don't add any users of DELAY_PAGER_CONFIG just yet, one will follow in a
      later patch.
      Suggested-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Martin Ågren's avatar
      builtin.h: take over documentation from api-builtin.txt · ec14d4ec
      Martin Ågren authored
      Delete Documentation/technical/api-builtin.txt and move its content
      into builtin.h. Format it as a comment. Remove a '+' which was needed
      when the information was formatted for AsciiDoc. Similarly, change
      "::" to ":".
      Document SUPPORT_SUPER_PREFIX, thereby bringing the documentation up to
      date with the available flags.
      While at it, correct '3 more things to do' to '4 more things to do'.
      Signed-off-by: default avatarMartin Ågren <martin.agren@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  10. 24 May, 2017 1 commit
  11. 09 Feb, 2017 1 commit
    • Johannes Schindelin's avatar
      rebase--helper: add a builtin helper for interactive rebases · 4557f1ad
      Johannes Schindelin authored
      Git's interactive rebase is still implemented as a shell script, despite
      its complexity. This implies that it suffers from the portability point
      of view, from lack of expressibility, and of course also from
      performance. The latter issue is particularly serious on Windows, where
      we pay a hefty price for relying so much on POSIX.
      Unfortunately, being such a huge shell script also means that we missed
      the train when it would have been relatively easy to port it to C, and
      instead piled feature upon feature onto that poor script that originally
      never intended to be more than a slightly pimped cherry-pick in a loop.
      To open the road toward better performance (in addition to all the other
      benefits of C over shell scripts), let's just start *somewhere*.
      The approach taken here is to add a builtin helper that at first intends
      to take care of the parts of the interactive rebase that are most
      affected by the performance penalties mentioned above.
      In particular, after we spent all those efforts on preparing the sequencer
      to process rebase -i's git-rebase-todo scripts, we implement the `git
      rebase -i --continue` functionality as a new builtin, git-rebase--helper.
      Once that is in place, we can work gradually on tackling the rest of the
      technical debt.
      Note that the rebase--helper needs to learn about the transient
      --ff/--no-ff options of git-rebase, as the corresponding flag is not
      persisted to, and re-read from, the state directory.
      Signed-off-by: Johannes Schindelin's avatarJohannes Schindelin <johannes.schindelin@gmx.de>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  12. 17 Jan, 2017 1 commit
  13. 07 Sep, 2016 1 commit
  14. 03 Sep, 2015 1 commit
    • Stefan Beller's avatar
      submodule: rewrite `module_list` shell function in C · 74703a1e
      Stefan Beller authored
      Most of the submodule operations work on a set of submodules.
      Calculating and using this set is usually done via:
             module_list "$@" | {
                 while read mode sha1 stage sm_path
                      # the actual operation
      Currently the function `module_list` is implemented in the
      git-submodule.sh as a shell script wrapping a perl script.
      The rewrite is in C, such that it is faster and can later be
      easily adapted when other functions are rewritten in C.
      git-submodule.sh, similar to the builtin commands, will navigate
      to the top-most directory of the repository and keep the
      subdirectory as a variable. As the helper is called from
      within the git-submodule.sh script, we are already navigated
      to the root level, but the path arguments are still relative
      to the subdirectory we were in when calling git-submodule.sh.
      That's why there is a `--prefix` option pointing to an alternative
      path which to anchor relative path arguments.
      Signed-off-by: Stefan Beller's avatarStefan Beller <sbeller@google.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  15. 05 Aug, 2015 1 commit
    • Paul Tan's avatar
      builtin-am: implement skeletal builtin am · 73c2779f
      Paul Tan authored
      For the purpose of rewriting git-am.sh into a C builtin, implement a
      skeletal builtin/am.c that redirects to $GIT_EXEC_PATH/git-am if the
      environment variable _GIT_USE_BUILTIN_AM is not defined. Since in the
      Makefile git-am.sh takes precedence over builtin/am.c,
      $GIT_EXEC_PATH/git-am will contain the shell script git-am.sh, and thus
      this allows us to fall back on the functional git-am.sh when running the
      test suite for tests that depend on a working git-am implementation.
      Since git-am.sh cannot handle any environment modifications by
      setup_git_directory(), "am" is declared with no setup flags in git.c. On
      the other hand, to re-implement git-am.sh in builtin/am.c, we need to
      run all the git dir and work tree setup logic that git.c typically does
      for us. As such, we work around this temporarily by copying the logic in
      git.c's run_builtin(), which is roughly:
      	prefix = setup_git_directory();
      This redirection should be removed when all the features of git-am.sh
      have been re-implemented in builtin/am.c.
      Helped-by: default avatarJunio C Hamano <gitster@pobox.com>
      Signed-off-by: default avatarPaul Tan <pyokagan@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  16. 29 Jun, 2015 1 commit
  17. 15 Jun, 2015 1 commit
    • Paul Tan's avatar
      pull: implement skeletal builtin pull · 1e1ea69f
      Paul Tan authored
      For the purpose of rewriting git-pull.sh into a C builtin, implement a
      skeletal builtin/pull.c that redirects to $GIT_EXEC_PATH/git-pull.sh if
      the environment variable _GIT_USE_BUILTIN_PULL is not defined. This
      allows us to fall back on the functional git-pull.sh when running the
      test suite for tests that depend on a working git-pull implementation.
      This redirection should be removed when all the features of git-pull.sh
      have been re-implemented in builtin/pull.c.
      Helped-by: default avatarJunio C Hamano <gitster@pobox.com>
      Signed-off-by: default avatarPaul Tan <pyokagan@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  18. 13 Oct, 2014 1 commit
  19. 23 Jun, 2014 1 commit
  20. 06 Jan, 2014 1 commit
  21. 12 Nov, 2013 1 commit
  22. 17 Sep, 2013 1 commit
    • Stefan Beller's avatar
      repack: rewrite the shell script in C · a1bbc6c0
      Stefan Beller authored
      The motivation of this patch is to get closer to a goal of being
      able to have a core subset of git functionality built in to git.
      That would mean
       * people on Windows could get a copy of at least the core parts
         of Git without having to install a Unix-style shell
       * people using git in on servers with chrooted environments
         do not need to worry about standard tools lacking for shell
      This patch is meant to be mostly a literal translation of the
      git-repack script; the intent is that later patches would start using
      more library facilities, but this patch is meant to be as close to a
      no-op as possible so it doesn't do that kind of thing.
      Signed-off-by: default avatarStefan Beller <stefanbeller@googlemail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  23. 13 Jul, 2013 1 commit
    • Eric Sunshine's avatar
      builtin: add git-check-mailmap command · 226ad348
      Eric Sunshine authored
      Introduce command check-mailmap, similar to check-attr and check-ignore,
      which allows direct testing of .mailmap configuration.
      As plumbing accessible to scripts and other porcelain, check-mailmap
      publishes the stable, well-tested .mailmap functionality employed by
      built-in Git commands.  Consequently, script authors need not
      re-implement .mailmap functionality manually, thus avoiding potential
      quirks and behavioral differences.
      Signed-off-by: Eric Sunshine's avatarEric Sunshine <sunshine@sunshineco.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  24. 12 Jun, 2013 2 commits
    • Johan Herland's avatar
      Move copy_note_for_rewrite + friends from builtin/notes.c to notes-utils.c · 49c24704
      Johan Herland authored
      This is a pure code movement of the machinery for copying notes to
      rewritten objects. This code was located in builtin/notes.c for
      historical reasons. In order to make it available to builtin/commit.c
      it was declared in builtin.h. This was more of an accident of history
      than a concious design, and we now want to make this machinery more
      widely available.
      Hence, this patch moves the code into the new notes-utils.[hc] files
      which are included into libgit.a. Except for adjusting #includes
      accordingly, this patch merely moves the relevant functions verbatim
      into the new files.
      Cc: Thomas Rast <trast@inf.ethz.ch>
      Signed-off-by: default avatarJohan Herland <johan@herland.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Johan Herland's avatar
      finish_copy_notes_for_rewrite(): Let caller provide commit message · 80a14665
      Johan Herland authored
      When copying notes for a rewritten object, the resulting notes commit
      would have the following hardcoded commit message:
        Notes added by 'git notes copy'
      This is obviously bogus when the notes rewriting is performed by
      'git commit --amend'.
      Therefore, let the caller specify an appropriate notes commit message
      instead of hardcoding it. The above message is used for 'git notes copy',
      but when calling finish_copy_notes_for_rewrite() from builtin/commit.c,
      we use the following message instead:
        Notes added by 'git commit --amend'
      Cc: Thomas Rast <trast@inf.ethz.ch>
      Signed-off-by: default avatarJohan Herland <johan@herland.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  25. 28 May, 2013 1 commit
    • Duy Nguyen's avatar
      prune-packed: avoid implying "1" is DRY_RUN in prune_packed_objects() · af0b4a3b
      Duy Nguyen authored
      Commit b60daf05 (Make git-prune-packed a bit more chatty. - 2007-01-12)
      changes the meaning of prune_packed_objects()'s argument, from "dry
      run or not dry run" to a bitmap.
      It however forgot to update prune_packed_objects() caller in
      builtin/prune.c to use new DRY_RUN macro. It's fine (for a long time!)
      but there is a risk that someday someone may change the value of
      DRY_RUN to something else and builtin/prune.c suddenly breaks. Avoid
      that possibility.
      While at there, change "opts == VERBOSE" to "opts & VERBOSE" as there
      is no obvious reason why we only be chatty when DRY_RUN is not set.
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  26. 06 Jan, 2013 1 commit
  27. 28 Dec, 2012 1 commit
    • Junio C Hamano's avatar
      merge --no-edit: do not credit people involved in the side branch · 9bcbb1c2
      Junio C Hamano authored
      The credit lines "By" and "Via" to credit authors and committers for
      their contributions on the side branch are meant as a hint to the
      integrator to decide whom to mention in the log message text.  After
      the integrator saves the message in the editor, they are meant to go
      away and that is why they are commented out.
      When a merge is recorded without editing the generated message,
      however, its contents do not go through the normal stripspace()
      and these lines are left in the merge.
      Stop producing them when we know the merge is going to be recorded
      without editing, i.e. when --no-edit is given.
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  28. 29 Oct, 2012 1 commit
  29. 16 Sep, 2012 1 commit
  30. 29 Jul, 2012 1 commit
    • Jeff King's avatar
      diff: do not use null sha1 as a sentinel value · e5450100
      Jeff King authored
      The diff code represents paths using the diff_filespec
      struct. This struct has a sha1 to represent the sha1 of the
      content at that path, as well as a sha1_valid member which
      indicates whether its sha1 field is actually useful. If
      sha1_valid is not true, then the filespec represents a
      working tree file (e.g., for the no-index case, or for when
      the index is not up-to-date).
      The diff_filespec is only used internally, though. At the
      interfaces to the diff subsystem, callers feed the sha1
      directly, and we create a diff_filespec from it. It's at
      that point that we look at the sha1 and decide whether it is
      valid or not; callers may pass the null sha1 as a sentinel
      value to indicate that it is not.
      We should not typically see the null sha1 coming from any
      other source (e.g., in the index itself, or from a tree).
      However, a corrupt tree might have a null sha1, which would
      cause "diff --patch" to accidentally diff the working tree
      version of a file instead of treating it as a blob.
      This patch extends the edges of the diff interface to accept
      a "sha1_valid" flag whenever we accept a sha1, and to use
      that flag when creating a filespec. In some cases, this
      means passing the flag through several layers, making the
      code change larger than would be desirable.
      One alternative would be to simply die() upon seeing
      corrupted trees with null sha1s. However, this fix more
      directly addresses the problem (while bogus sha1s in a tree
      are probably a bad thing, it is really the sentinel
      confusion sending us down the wrong code path that is what
      makes it devastating). And it means that git is more capable
      of examining and debugging these corrupted trees. For
      example, you can still "diff --raw" such a tree to find out
      when the bogus entry was introduced; you just cannot do a
      "--patch" diff (just as you could not with any other
      corrupted tree, as we do not have any content to diff).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  31. 25 Jun, 2012 1 commit
  32. 15 Jun, 2012 2 commits
    • Jeff King's avatar
      fix pager.diff with diff --no-index · 1af3d977
      Jeff King authored
      git-diff does not rely on the git wrapper to setup its
      pager; instead, it sets it up on its own after seeing
      whether --quiet or --exit-code has been specified.  After
      diff_no_index was split off from cmd_diff, commit b3fde6cc
      (git diff --no-index: default to page like other diff
      frontends, 2008-05-26) duplicated the one-liner from
      cmd_diff to turn on the pager.
      Later, commit 8f0359f0 (Allow pager of diff command be
      enabled/disabled, 2008-07-21) taught the the version in
      cmd_diff to respect the pager.diff config, but the version
      in diff_no_index was left behind. This meant that
        git -c pager.diff=0 diff a b
      would not use a pager, but
        git -c pager.diff=0 diff --no-index a b
      would.  Let's fix it by factoring out a common function.
      While we're there, let's update the antiquated comment,
      which claims that the pager interferes with propagating the
      exit code; this has not been the case since ea27a18c (spawn
      pager via run_command interface, 2008-07-22).
      Signed-off-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
    • Luka Perkov's avatar
      builtin.h: remove unused cmd_<foo> declarations · 0feb7c66
      Luka Perkov authored
      These were left in builtin.h after they were converted into
      stand-alone programs or removed after experiments finished.
      Signed-off-by: default avatarLuka Perkov <lists@lukaperkov.net>
      Helped-by: default avatarJeff King <peff@peff.net>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  33. 03 Jun, 2012 1 commit
  34. 27 Apr, 2012 1 commit
    • Duy Nguyen's avatar
      Add column layout skeleton and git-column · 7e29b825
      Duy Nguyen authored
      A column option string consists of many token separated by either
      a space or a  comma. A token belongs to one of three groups:
       - enabling: always, never and auto
       - layout mode: currently plain (which does not layout at all)
       - other future tuning flags
      git-column can be used to pipe output to from a command that wants
      column layout, but not to mess with its own output code. Simpler output
      code can be changed to use column layout code directly.
      Thanks-to: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
      Signed-off-by: Duy Nguyen's avatarNguyễn Thái Ngọc Duy <pclouds@gmail.com>
      Signed-off-by: default avatarJunio C Hamano <gitster@pobox.com>
  35. 21 Nov, 2011 1 commit