commit - 6d23ec10d58455c5dd25839caf9e0b84461c4acb
commit + a7c9878d5b0e7770339e76efc0821897fe7a6be8
blob - 3f39bc910f78147e8018edefbed523871fd89043
blob + 022dc3679c92b06dec343178983f00ab324b3b4e
--- got/got.c
+++ got/got.c
}
static const struct got_error *
-show_change(unsigned char status, const char *path, FILE *patch_file)
+show_change(unsigned char status, const char *path, FILE *patch_file, int n,
+ int nchanges)
{
char *line = NULL;
size_t linesize = 0;
if (ferror(patch_file))
return got_error_from_errno("getline");
printf(GOT_COMMIT_SEP_STR);
- printf("M %s\nstage this change? [y/n/q] ", path);
+ printf("M %s (change %d of %d)\nstage this change? [y/n/q] ",
+ path, n, nchanges);
break;
default:
return got_error_path(path, GOT_ERR_FILE_STATUS);
static const struct got_error *
choose_patch(int *choice, void *arg, unsigned char status, const char *path,
- FILE *patch_file)
+ FILE *patch_file, int n, int nchanges)
{
const struct got_error *err = NULL;
char *line = NULL;
nl = strchr(line, '\n');
if (nl)
*nl = '\0';
- err = show_change(status, path, patch_file);
+ err = show_change(status, path, patch_file, n, nchanges);
if (err)
return err;
if (strcmp(line, "y") == 0) {
}
while (resp != 'y' && resp != 'n' && resp != 'q') {
- err = show_change(status, path, patch_file);
+ err = show_change(status, path, patch_file, n, nchanges);
if (err)
return err;
resp = getchar();
blob - c4b942501561a17043e8895b1f6f2779fd3ebb10
blob + b07be0075e7e1ea62cda811facea1131cf1463c0
--- include/got_worktree.h
+++ include/got_worktree.h
/* A callback function which is used to select or reject a patch. */
typedef const struct got_error *(*got_worktree_patch_cb)(int *, void *,
- unsigned char, const char *, FILE *);
+ unsigned char, const char *, FILE *, int, int);
/* Values for result output parameter of got_wortree_patch_cb. */
#define GOT_PATCH_CHOICE_NONE 0
blob - 496525cdbab66eb5140f3e444ebb242457424957
blob + e3af9a1729612641589c1819b36dbbbb23207911
--- lib/got_lib_diff.h
+++ lib/got_lib_diff.h
};
struct got_diff_changes {
- size_t nchanges;
+ int nchanges;
SIMPLEQ_HEAD(, got_diff_change) entries;
};
blob - 7de42bb2933ea1ece79a2ae3b05f4d3eec9aa4cc
blob + 73c9e659a5d078b48f853bb0fb2ebf16cedef6f0
--- lib/worktree.c
+++ lib/worktree.c
}
static const struct got_error *
-apply_or_reject_change(int *choice, struct got_diff_change *change,
- struct got_diff_state *ds, struct got_diff_args *args, int diff_flags,
- const char *relpath, FILE *f1, FILE *f2, int *line_cur1, int *line_cur2,
- FILE *outfile, got_worktree_patch_cb patch_cb, void *patch_arg)
+apply_or_reject_change(int *choice, struct got_diff_change *change, int n,
+ int nchanges, struct got_diff_state *ds, struct got_diff_args *args,
+ int diff_flags, const char *relpath, FILE *f1, FILE *f2, int *line_cur1,
+ int *line_cur2, FILE *outfile, got_worktree_patch_cb patch_cb,
+ void *patch_arg)
{
const struct got_error *err = NULL;
int start_old = change->cv.a;
}
err = (*patch_cb)(choice, patch_arg, GOT_STATUS_MODIFY, relpath,
- hunkfile);
+ hunkfile, n, nchanges);
if (err)
goto done;
struct got_diff_args *args = NULL;
struct got_diff_change *change;
int diff_flags = 0, line_cur1 = 1, line_cur2 = 1, have_content = 0;
+ int n = 0;
*path_outfile = NULL;
return got_ferror(f2, GOT_ERR_IO);
SIMPLEQ_FOREACH(change, &changes->entries, entry) {
int choice;
- err = apply_or_reject_change(&choice, change, ds, args,
- diff_flags, relpath, f1, f2, &line_cur1, &line_cur2,
+ err = apply_or_reject_change(&choice, change, ++n,
+ changes->nchanges, ds, args, diff_flags, relpath,
+ f1, f2, &line_cur1, &line_cur2,
outfile, patch_cb, patch_arg);
if (err)
goto done;
if (status == GOT_STATUS_ADD) {
int choice = GOT_PATCH_CHOICE_NONE;
err = (*a->patch_cb)(&choice, a->patch_arg,
- status, ie->path, NULL);
+ status, ie->path, NULL, 1, 1);
if (err)
break;
if (choice != GOT_PATCH_CHOICE_YES)
if (a->patch_cb) {
int choice = GOT_PATCH_CHOICE_NONE;
err = (*a->patch_cb)(&choice, a->patch_arg, status,
- ie->path, NULL);
+ ie->path, NULL, 1, 1);
if (err)
break;
if (choice != GOT_PATCH_CHOICE_YES)
blob - 83c66f0ba6329c5e2da2747a82ae24dbdf3000cd
blob + 3d1f624eae4a18cd9f42dbc35954c703cf11bc54
--- regress/cmdline/stage.sh
+++ regress/cmdline/stage.sh
4
5
-----------------------------------------------
-M numbers
+M numbers (change 1 of 3)
stage this change? [y/n/q] n
-----------------------------------------------
@@ -4,7 +4,7 @@
9
10
-----------------------------------------------
-M numbers
+M numbers (change 2 of 3)
stage this change? [y/n/q] n
-----------------------------------------------
@@ -13,4 +13,4 @@
-16
+c
-----------------------------------------------
-M numbers
+M numbers (change 3 of 3)
stage this change? [y/n/q] n
EOF
cmp -s $testroot/stdout.expected $testroot/stdout
4
5
-----------------------------------------------
-M numbers
+M numbers (change 1 of 3)
stage this change? [y/n/q] n
-----------------------------------------------
@@ -4,7 +4,7 @@
9
10
-----------------------------------------------
-M numbers
+M numbers (change 2 of 3)
stage this change? [y/n/q] y
-----------------------------------------------
@@ -13,4 +13,4 @@
-16
+c
-----------------------------------------------
-M numbers
+M numbers (change 3 of 3)
stage this change? [y/n/q] n
EOF
cmp -s $testroot/stdout.expected $testroot/stdout
4
5
-----------------------------------------------
-M numbers
+M numbers (change 1 of 3)
stage this change? [y/n/q] n
-----------------------------------------------
@@ -4,7 +4,7 @@
9
10
-----------------------------------------------
-M numbers
+M numbers (change 2 of 3)
stage this change? [y/n/q] n
-----------------------------------------------
@@ -13,4 +13,4 @@
-16
+c
-----------------------------------------------
-M numbers
+M numbers (change 3 of 3)
stage this change? [y/n/q] y
EOF
cmp -s $testroot/stdout.expected $testroot/stdout
4
5
-----------------------------------------------
-M numbers
+M numbers (change 1 of 3)
stage this change? [y/n/q] y
-----------------------------------------------
@@ -4,7 +4,7 @@
9
10
-----------------------------------------------
-M numbers
+M numbers (change 2 of 3)
stage this change? [y/n/q] q
EOF
cmp -s $testroot/stdout.expected $testroot/stdout