summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/add.c126
-rw-r--r--builtin/am.c209
-rw-r--r--builtin/archive.c19
-rw-r--r--builtin/bisect--helper.c580
-rw-r--r--builtin/blame.c136
-rw-r--r--builtin/branch.c61
-rw-r--r--builtin/bundle.c217
-rw-r--r--builtin/cat-file.c43
-rw-r--r--builtin/check-attr.c1
-rw-r--r--builtin/check-ignore.c38
-rw-r--r--builtin/checkout-index.c11
-rw-r--r--builtin/checkout.c1194
-rw-r--r--builtin/clean.c55
-rw-r--r--builtin/clone.c204
-rw-r--r--builtin/column.c2
-rw-r--r--builtin/commit-graph.c213
-rw-r--r--builtin/commit-tree.c152
-rw-r--r--builtin/commit.c236
-rw-r--r--builtin/config.c51
-rw-r--r--builtin/count-objects.c4
-rw-r--r--builtin/describe.c65
-rw-r--r--builtin/diff-files.c1
-rw-r--r--builtin/diff-index.c1
-rw-r--r--builtin/diff-tree.c18
-rw-r--r--builtin/diff.c47
-rw-r--r--builtin/difftool.c97
-rw-r--r--builtin/env--helper.c95
-rw-r--r--builtin/fast-export.c321
-rw-r--r--builtin/fetch-pack.c16
-rw-r--r--builtin/fetch.c456
-rw-r--r--builtin/fmt-merge-msg.c656
-rw-r--r--builtin/for-each-ref.c3
-rw-r--r--builtin/fsck.c324
-rw-r--r--builtin/gc.c62
-rw-r--r--builtin/get-tar-commit-id.c14
-rw-r--r--builtin/grep.c233
-rw-r--r--builtin/hash-object.c5
-rw-r--r--builtin/help.c92
-rw-r--r--builtin/index-pack.c55
-rw-r--r--builtin/init-db.c98
-rw-r--r--builtin/interpret-trailers.c7
-rw-r--r--builtin/log.c374
-rw-r--r--builtin/ls-files.c54
-rw-r--r--builtin/ls-remote.c3
-rw-r--r--builtin/ls-tree.c3
-rw-r--r--builtin/merge-base.c12
-rw-r--r--builtin/merge-index.c1
-rw-r--r--builtin/merge-ours.c3
-rw-r--r--builtin/merge-recursive.c21
-rw-r--r--builtin/merge-tree.c51
-rw-r--r--builtin/merge.c248
-rw-r--r--builtin/mktag.c7
-rw-r--r--builtin/mktree.c4
-rw-r--r--builtin/multi-pack-index.c29
-rw-r--r--builtin/mv.c1
-rw-r--r--builtin/name-rev.c309
-rw-r--r--builtin/notes.c61
-rw-r--r--builtin/pack-objects.c470
-rw-r--r--builtin/pack-redundant.c238
-rw-r--r--builtin/pack-refs.c2
-rw-r--r--builtin/patch-id.c33
-rw-r--r--builtin/prune-packed.c49
-rw-r--r--builtin/prune.c46
-rw-r--r--builtin/pull.c136
-rw-r--r--builtin/push.c110
-rw-r--r--builtin/range-diff.c35
-rw-r--r--builtin/read-tree.c24
-rw-r--r--builtin/rebase--interactive.c271
-rw-r--r--builtin/rebase.c1572
-rw-r--r--builtin/receive-pack.c212
-rw-r--r--builtin/reflog.c49
-rw-r--r--builtin/remote.c200
-rw-r--r--builtin/repack.c70
-rw-r--r--builtin/replace.c38
-rw-r--r--builtin/rerere.c10
-rw-r--r--builtin/reset.c63
-rw-r--r--builtin/rev-list.c172
-rw-r--r--builtin/rev-parse.c34
-rw-r--r--builtin/revert.c23
-rw-r--r--builtin/rm.c41
-rw-r--r--builtin/send-pack.c15
-rw-r--r--builtin/serve.c30
-rw-r--r--builtin/shortlog.c4
-rw-r--r--builtin/show-branch.c15
-rw-r--r--builtin/show-index.c13
-rw-r--r--builtin/show-ref.c17
-rw-r--r--builtin/sparse-checkout.c620
-rw-r--r--builtin/stash.c1615
-rw-r--r--builtin/stripspace.c3
-rw-r--r--builtin/submodule--helper.c126
-rw-r--r--builtin/tag.c58
-rw-r--r--builtin/unpack-objects.c8
-rw-r--r--builtin/update-index.c83
-rw-r--r--builtin/update-ref.c245
-rw-r--r--builtin/upload-pack.c2
-rw-r--r--builtin/verify-commit.c24
-rw-r--r--builtin/verify-tag.c1
-rw-r--r--builtin/worktree.c77
-rw-r--r--builtin/write-tree.c13
99 files changed, 9787 insertions, 4479 deletions
diff --git a/builtin/add.c b/builtin/add.c
index f65c172299..298e0114f9 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2006 Linus Torvalds
*/
+#define USE_THE_INDEX_COMPATIBILITY_MACROS
#include "cache.h"
#include "config.h"
#include "builtin.h"
@@ -19,6 +20,7 @@
#include "bulk-checkin.h"
#include "argv-array.h"
#include "submodule.h"
+#include "add-interactive.h"
static const char * const builtin_add_usage[] = {
N_("git add [<options>] [--] <pathspec>..."),
@@ -27,6 +29,9 @@ static const char * const builtin_add_usage[] = {
static int patch_interactive, add_interactive, edit_interactive;
static int take_worktree_changes;
static int add_renormalize;
+static int pathspec_file_nul;
+static const char *pathspec_from_file;
+static int legacy_stash_p; /* support for the scripted `git stash` */
struct update_callback_data {
int flags;
@@ -137,7 +142,7 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags)
continue; /* do not touch non blobs */
if (pathspec && !ce_path_match(&the_index, ce, pathspec, NULL))
continue;
- retval |= add_file_to_cache(ce->name, flags | HASH_RENORMALIZE);
+ retval |= add_file_to_cache(ce->name, flags | ADD_CACHE_RENORMALIZE);
}
return retval;
@@ -176,7 +181,7 @@ static void refresh(int verbose, const struct pathspec *pathspec)
die(_("pathspec '%s' did not match any files"),
pathspec->items[i].match);
}
- free(seen);
+ free(seen);
}
int run_add_interactive(const char *revision, const char *patch_mode,
@@ -184,6 +189,34 @@ int run_add_interactive(const char *revision, const char *patch_mode,
{
int status, i;
struct argv_array argv = ARGV_ARRAY_INIT;
+ int use_builtin_add_i =
+ git_env_bool("GIT_TEST_ADD_I_USE_BUILTIN", -1);
+
+ if (use_builtin_add_i < 0)
+ git_config_get_bool("add.interactive.usebuiltin",
+ &use_builtin_add_i);
+
+ if (use_builtin_add_i == 1) {
+ enum add_p_mode mode;
+
+ if (!patch_mode)
+ return !!run_add_i(the_repository, pathspec);
+
+ if (!strcmp(patch_mode, "--patch"))
+ mode = ADD_P_ADD;
+ else if (!strcmp(patch_mode, "--patch=stash"))
+ mode = ADD_P_STASH;
+ else if (!strcmp(patch_mode, "--patch=reset"))
+ mode = ADD_P_RESET;
+ else if (!strcmp(patch_mode, "--patch=checkout"))
+ mode = ADD_P_CHECKOUT;
+ else if (!strcmp(patch_mode, "--patch=worktree"))
+ mode = ADD_P_WORKTREE;
+ else
+ die("'%s' not supported", patch_mode);
+
+ return !!run_add_p(the_repository, mode, revision, pathspec);
+ }
argv_array_push(&argv, "add--interactive");
if (patch_mode)
@@ -239,7 +272,7 @@ static int edit_patch(int argc, const char **argv, const char *prefix)
rev.diffopt.output_format = DIFF_FORMAT_PATCH;
rev.diffopt.use_color = 0;
rev.diffopt.flags.ignore_dirty_submodules = 1;
- out = open(file, O_CREAT | O_WRONLY, 0666);
+ out = open(file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (out < 0)
die(_("Could not open '%s' for writing."), file);
rev.diffopt.file = xfdopen(out, "w");
@@ -297,10 +330,10 @@ static struct option builtin_add_options[] = {
OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
- { OPTION_CALLBACK, 0, "ignore-removal", &addremove_explicit,
+ OPT_CALLBACK_F(0, "ignore-removal", &addremove_explicit,
NULL /* takes no arguments */,
N_("ignore paths removed in the working tree (same as --no-all)"),
- PARSE_OPT_NOARG, ignore_removal_cb },
+ PARSE_OPT_NOARG, ignore_removal_cb),
OPT_BOOL( 0 , "refresh", &refresh_only, N_("don't add, only refresh the index")),
OPT_BOOL( 0 , "ignore-errors", &ignore_add_errors, N_("just skip files which cannot be added because of errors")),
OPT_BOOL( 0 , "ignore-missing", &ignore_missing, N_("check if - even missing - files are ignored in dry run")),
@@ -308,6 +341,10 @@ static struct option builtin_add_options[] = {
N_("override the executable bit of the listed files")),
OPT_HIDDEN_BOOL(0, "warn-embedded-repo", &warn_on_embedded_repo,
N_("warn when adding an embedded repository")),
+ OPT_HIDDEN_BOOL(0, "legacy-stash-p", &legacy_stash_p,
+ N_("backend for `git stash -p`")),
+ OPT_PATHSPEC_FROM_FILE(&pathspec_from_file),
+ OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul),
OPT_END(),
};
@@ -318,6 +355,7 @@ static int add_config(const char *var, const char *value, void *cb)
ignore_add_errors = git_config_bool(var, value);
return 0;
}
+
return git_default_config(var, value, cb);
}
@@ -368,16 +406,20 @@ static int add_files(struct dir_struct *dir, int flags)
fprintf(stderr, _(ignore_error));
for (i = 0; i < dir->ignored_nr; i++)
fprintf(stderr, "%s\n", dir->ignored[i]->name);
- fprintf(stderr, _("Use -f if you really want to add them.\n"));
+ if (advice_add_ignored_file)
+ advise(_("Use -f if you really want to add them.\n"
+ "Turn this message off by running\n"
+ "\"git config advice.addIgnoredFile false\""));
exit_status = 1;
}
for (i = 0; i < dir->nr; i++) {
- check_embedded_repo(dir->entries[i]->name);
if (add_file_to_index(&the_index, dir->entries[i]->name, flags)) {
if (!ignore_add_errors)
die(_("adding files failed"));
exit_status = 1;
+ } else {
+ check_embedded_repo(dir->entries[i]->name);
}
}
return exit_status;
@@ -400,11 +442,28 @@ int cmd_add(int argc, const char **argv, const char *prefix)
builtin_add_usage, PARSE_OPT_KEEP_ARGV0);
if (patch_interactive)
add_interactive = 1;
- if (add_interactive)
+ if (add_interactive) {
+ if (pathspec_from_file)
+ die(_("--pathspec-from-file is incompatible with --interactive/--patch"));
exit(interactive_add(argc - 1, argv + 1, prefix, patch_interactive));
+ }
+ if (legacy_stash_p) {
+ struct pathspec pathspec;
+
+ parse_pathspec(&pathspec, 0,
+ PATHSPEC_PREFER_FULL |
+ PATHSPEC_SYMLINK_LEADING_PATH |
+ PATHSPEC_PREFIX_ORIGIN,
+ prefix, argv);
+
+ return run_add_interactive(NULL, "--patch=stash", &pathspec);
+ }
- if (edit_interactive)
+ if (edit_interactive) {
+ if (pathspec_from_file)
+ die(_("--pathspec-from-file is incompatible with --edit"));
return(edit_patch(argc, argv, prefix));
+ }
argc--;
argv++;
@@ -416,10 +475,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
if (addremove && take_worktree_changes)
die(_("-A and -u are mutually incompatible"));
- if (!take_worktree_changes && addremove_explicit < 0 && argc)
- /* Turn "git add pathspec..." to "git add -A pathspec..." */
- addremove = 1;
-
if (!show_only && ignore_missing)
die(_("Option --ignore-missing can only be used together with --dry-run"));
@@ -432,19 +487,6 @@ int cmd_add(int argc, const char **argv, const char *prefix)
hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR);
- flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
- (show_only ? ADD_CACHE_PRETEND : 0) |
- (intent_to_add ? ADD_CACHE_INTENT : 0) |
- (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
- (!(addremove || take_worktree_changes)
- ? ADD_CACHE_IGNORE_REMOVAL : 0));
-
- if (require_pathspec && argc == 0) {
- fprintf(stderr, _("Nothing specified, nothing added.\n"));
- fprintf(stderr, _("Maybe you wanted to say 'git add .'?\n"));
- return 0;
- }
-
/*
* Check the "pathspec '%s' did not match any files" block
* below before enabling new magic.
@@ -454,6 +496,38 @@ int cmd_add(int argc, const char **argv, const char *prefix)
PATHSPEC_SYMLINK_LEADING_PATH,
prefix, argv);
+ if (pathspec_from_file) {
+ if (pathspec.nr)
+ die(_("--pathspec-from-file is incompatible with pathspec arguments"));
+
+ parse_pathspec_file(&pathspec, PATHSPEC_ATTR,
+ PATHSPEC_PREFER_FULL |
+ PATHSPEC_SYMLINK_LEADING_PATH,
+ prefix, pathspec_from_file, pathspec_file_nul);
+ } else if (pathspec_file_nul) {
+ die(_("--pathspec-file-nul requires --pathspec-from-file"));
+ }
+
+ if (require_pathspec && pathspec.nr == 0) {
+ fprintf(stderr, _("Nothing specified, nothing added.\n"));
+ if (advice_add_empty_pathspec)
+ advise( _("Maybe you wanted to say 'git add .'?\n"
+ "Turn this message off by running\n"
+ "\"git config advice.addEmptyPathspec false\""));
+ return 0;
+ }
+
+ if (!take_worktree_changes && addremove_explicit < 0 && pathspec.nr)
+ /* Turn "git add pathspec..." to "git add -A pathspec..." */
+ addremove = 1;
+
+ flags = ((verbose ? ADD_CACHE_VERBOSE : 0) |
+ (show_only ? ADD_CACHE_PRETEND : 0) |
+ (intent_to_add ? ADD_CACHE_INTENT : 0) |
+ (ignore_add_errors ? ADD_CACHE_IGNORE_ERRORS : 0) |
+ (!(addremove || take_worktree_changes)
+ ? ADD_CACHE_IGNORE_REMOVAL : 0));
+
if (read_cache_preload(&pathspec) < 0)
die(_("index file corrupt"));
diff --git a/builtin/am.c b/builtin/am.c
index 8f27f3375b..e3dfd93c25 100644
--- a/builtin/am.c
+++ b/built