@@ -35,6 +35,7 @@ the mirror on GitHub.
35
35
36
36
----
37
37
$ git clone https://github.com/git/git git
38
+ $ cd git
38
39
----
39
40
40
41
[[identify-problem]]
@@ -164,8 +165,28 @@ $ ./bin-wrappers/git psuh
164
165
165
166
Check it out! You've got a command! Nice work! Let's commit this.
166
167
168
+ `git status` reveals modified `Makefile`, `builtin.h`, and `git.c` as well as
169
+ untracked `builtin/psuh.c` and `git-psuh`. First, let's take care of the binary,
170
+ which should be ignored. Open `.gitignore` in your editor, find `/git-push`, and
171
+ add an entry for your new command in alphabetical order:
172
+
173
+ ----
174
+ ...
175
+ /git-prune-packed
176
+ /git-psuh
177
+ /git-pull
178
+ /git-push
179
+ /git-quiltimport
180
+ /git-range-diff
181
+ ...
182
+ ----
183
+
184
+ Checking `git status` again should show that `git-psuh` has been removed from
185
+ the untracked list and `.gitignore` has been added to the modified list. Now we
186
+ can stage and commit:
187
+
167
188
----
168
- $ git add Makefile builtin.h builtin/psuh.c git.c
189
+ $ git add Makefile builtin.h builtin/psuh.c git.c .gitignore
169
190
$ git commit -s
170
191
----
171
192
@@ -211,7 +232,8 @@ on the reference implementation linked at the top of this document.
211
232
It's probably useful to do at least something besides printing out a string.
212
233
Let's start by having a look at everything we get.
213
234
214
- Modify your `cmd_psuh` implementation to dump the args you're passed:
235
+ Modify your `cmd_psuh` implementation to dump the args you're passed, keeping
236
+ existing `printf()` calls in place:
215
237
216
238
----
217
239
int i;
@@ -243,7 +265,7 @@ function body:
243
265
244
266
...
245
267
246
- git_config(git_default_config, NULL)
268
+ git_config(git_default_config, NULL);
247
269
if (git_config_get_string_const("user.name", &cfg_name) > 0)
248
270
printf(_("No name is found in config\n"));
249
271
else
@@ -315,6 +337,7 @@ Run it again. Check it out - here's the (verbose) name of your current branch!
315
337
Let's commit this as well.
316
338
317
339
----
340
+ $ git add builtin/psuh.c
318
341
$ git commit -sm "psuh: print the current branch"
319
342
----
320
343
@@ -366,6 +389,7 @@ see the subject line of the most recent commit in `origin/master` that you know
366
389
about. Neat! Let's commit that as well.
367
390
368
391
----
392
+ $ git add builtin/psuh.c
369
393
$ git commit -sm "psuh: display the top of origin/master"
370
394
----
371
395
@@ -418,7 +442,6 @@ OUTPUT
418
442
------
419
443
...
420
444
421
-
422
445
GIT
423
446
---
424
447
Part of the linkgit:git[1] suite
0 commit comments