-
Notifications
You must be signed in to change notification settings - Fork 0
/
project_structure.txt
2595 lines (2178 loc) · 140 KB
/
project_structure.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--- Folder Structure ---
[.git]
├── COMMIT_EDITMSG
├── FETCH_HEAD
├── HEAD
├── ORIG_HEAD
├── config
├── description
├── [hooks]
├── applypatch-msg.sample
├── commit-msg.sample
├── fsmonitor-watchman.sample
├── post-update.sample
├── pre-applypatch.sample
├── pre-commit.sample
├── pre-merge-commit.sample
├── pre-push.sample
├── pre-rebase.sample
├── pre-receive.sample
├── prepare-commit-msg.sample
├── push-to-checkout.sample
└── update.sample
├── index
├── [info]
└── exclude
├── [logs]
├── HEAD
└── [refs]
├── [heads]
└── [remotes]
└── [origin]
├── [objects]
├── [02]
└── 453251f41f2fb8df2a43d782e4a677a255421d
├── [05]
└── c4b3967013bc91f2f69a8e78a199294d356460
├── [06]
└── e06218446a32b73ecd90403976c97e26fb3373
├── [08]
└── a34bdd48fb85450421ec26c84e378efea88638
├── [11]
└── d963e92a9cd3df9d0f7d16fe71464dbf6f8a94
├── [12]
└── 4c42666f183d17afbed05d5c73e1bf7d2b9523
├── [13]
└── d1de5edb76353fbd050e2f7e6c128c3aea47cd
├── [14]
└── 6df61a8ad751d4ac7584b7363cb99575662ebe
├── [18]
├── 4274ddc9a547892f2bd25e2a4d741075838895
└── 5beb0716b52b1d661c9aece913a4c15c4a8372
├── [1e]
└── a3fd46bfcc16ad2cb77dc8ce984caeb3827935
├── [1f]
└── 2b9de280dd49c5c99f3ca52c871ab8667c6a23
├── [20]
└── 2588a91d4b3ff7891ab06aa82acad0efe24fe5
├── [22]
└── 39ca9a73e180851024d434a5b97ef117a1d1fe
├── [23]
├── 49795c6d05b83cdef736ebecab1e0f8d671ab7
└── d7f0d32c34675223aa4b635beda868a9abb8eb
├── [27]
└── 4e30a7d58107f8f5e1b0513be08075b321db53
├── [28]
└── 3033e6d925f6d68b64504f2b3fd12a5139ed3b
├── [2b]
└── 7177e4893333d893a0b10c2554631d1b56e09c
├── [34]
└── be04d71b39d3ba736a6f219af4c1c912ceeffb
├── [36]
├── 96ba8fa14acc57ee387c177f8ae83c44bee862
├── a1c4b1882a1f8ba7c8657e89f8ede3fbcdbac7
└── efc16c213a74b3726299e99e17537147ad2bf5
├── [37]
└── 23961d2e27e3ff913eeba36105e3d06bbd1ba8
├── [3b]
└── 0d45455fa59ca5046d08eb5db1bf0d9c413ee1
├── [3c]
└── fb116c749a8ae4a465ea9780ac223c39aee344
├── [3d]
└── a502d9b8d648d3d5ec0ee160a02dbc387fb7dc
├── [3e]
└── 546e2e9950fe1a41ab864f82fbad67eb7004fc
├── [3f]
└── b42eda8a61252bdd08aad4e5ca011d818e7742
├── [43]
├── 6abd643292075a5725a528a0495d101af10bb0
└── a6a1e9522f22046dc90d4379c231aeaf599c12
├── [48]
├── 54a13b3fad9a7344c8a4d843510848964b5370
└── a7e45d1ac15062da031c13eb264cbc3114301c
├── [4b]
└── 825dc642cb6eb9a060e54bf8d69288fbee4904
├── [4f]
└── a1288efb7e11d2fc52c855b7a405a8e383f08c
├── [50]
├── 254294998c5bebcca115844769ba873a9d8477
└── d2815650a24f1c1e4fa8237ad00d8b7198375a
├── [52]
└── 46485209208591e0f1c9157c361bf8347d8fd1
├── [54]
├── 20049f0d001009ece837f6d3cde3201a0e2ef7
└── 61f8c8f32fe32ab0fe7983939b609a4839db39
├── [57]
└── a46d2837f79018e69b745e2a6f5bf928b81297
├── [59]
└── a3d00f5c0b8efff4187d1cb1e404d15494e47c
├── [5c]
├── 1a97f9b91e7d7bba42cd7d84366c4acc94c070
└── 8abab790a4d3890d08f4a310bb91f9fa57b8ac
├── [5d]
└── ceddd20ee274459e422d485a4c97de2712cb74
├── [5e]
├── 32c7150dc4dfd3f954d383b35f7cc733cfc457
└── cdf88cdd85945a00edf3443cea595759c33bbd
├── [5f]
└── 3e90af7dc24356a1e5391053588ce62221c5bc
├── [62]
├── 26d5377ef19af1396ca7b6151f32ae3e2a9d30
├── 57b69de75bcb05ee621595d2ee83f10206bc85
└── dbc565412ce0fa127a6b32ee64241d732a2bf2
├── [63]
└── 5df2399a68d252ce0f6d37903d9bee872301ce
├── [66]
└── ebc8c7846fe181a41532307eb593d1570ee793
├── [68]
└── 7fe63e37183aca54722dd98ac3fb0f7ccb43ce
├── [69]
└── 19efc6455f0ff6da5cc138b9c506a9bf1c5ff1
├── [6a]
├── 297189f52ca456ceb93246beed8c4be9bf70ef
└── 50c8da6c525036d3568916bb183cc175e61f45
├── [6b]
└── 8fe50e2bb128a87a0fd8dc526e43dad7dfdd5c
├── [6d]
└── e2c31dea18b8be8c45c0210f472169ab071035
├── [70]
└── 1b341c12ad59a609bc794becdf500624a837dd
├── [7e]
└── 25c1eada27907abd40314ffb5a18739bf32efb
├── [7f]
└── a3c03f181e901ff37601b07139d64ed2d96c58
├── [80]
└── 84efcae258dc9347329c87d5f0f7a1701aaf33
├── [81]
├── 427cc81e3d6330fc35493c6b77fb2730afc3f4
├── 7f11a85520a84ba2fea921553246fbf9c4165f
└── cf465800fb20f4a2483d6c81a0c962d04b2cc1
├── [82]
└── 66edf99fd7f07988a5d4b8cc72645d96cc0859
├── [84]
├── 0ca0295b08785601794eb40f3a18e55317854a
└── 23248104913e842e0ae11dfda5c7c51b1d718d
├── [86]
└── bd3056f3665d07da5e4707f7a0c7f197b889fc
├── [87]
└── c1083a7547b97d5f9d8cb6aea04959da4162fe
├── [89]
└── d473e38a417dcd5865e059a1d59f015864c3b9
├── [8b]
├── 9c2695e28b7d1998246de7ac4a87c056edcd6a
└── ca0a9b9fe14db71e045f2a9c0465c619554ddd
├── [8d]
├── 5adf8c3dfade12c092beb10aeb7f72d49169b4
└── c85b6ac78fc442ae379bd4e21c3ece8a0583d0
├── [93]
└── b9311dfc1a06173ffa1966f0e438237ae3f8c9
├── [94]
├── 3cd42fe23ff86a64cc987022d36c3032db1f77
└── dda9a80e4cf527b473ea1e8164c5f9b8bf1ea5
├── [98]
└── 5afaf19067092b743c68f2493d977de3f8b72f
├── [99]
├── 0f24a80877c199dbd9e2b093ec6f0dec406bc1
└── f7f40e42c8be548af42b5df2aad07d2e36a5bb
├── [9d]
└── 2144457799ca781695d0613a7334b195abe612
├── [9e]
└── 628721545c669f0d7135789df865805e8e8676
├── [a0]
└── 550a80db9bce1c4b8a24c8de63d02190e59fb8
├── [a1]
└── 36cb92ae75e483ded415fda7b1cb3af55538a0
├── [a3]
├── 612ffc89a03c4681924b2dbadd70231ca22a6a
├── b8aa00f28e6d5111f01dc1f664a87ff481277f
└── bf5935250432a8193665d9e6265b9d5dea846f
├── [a4]
├── 132796d74a8c3680228ad7694df13f9743248b
├── cadbdac5559bbe840bd63ef79ce318f6a75d1e
└── fcbdd72f6683466888fd65093d556a64175753
├── [a8]
└── 0037bef5cc91a26c8838e8334595a5639cdca9
├── [a9]
└── 6665b9821b003984d241f533189e3cc553515e
├── [ab]
└── 920f04e4b94ea43d73760d8dfb8c2a6bb34705
├── [ac]
└── b7d12fcd7a961dd55288a16d27777d701f5d7e
├── [ae]
└── c8d15132afc9e740d8a811d4a8d5d3c4fdefb9
├── [b1]
└── ad8357b8fc28047dd9b64f0627ef64252b9892
├── [b3]
└── 14e3e068acea0f5bc309c3e57775909f45d43b
├── [b7]
└── 50aadc0ffa3414b8a74216060ee7920c4ac252
├── [bc]
└── a568d7a37eb6a8c66ae4101e6cd6aaf12394dd
├── [be]
└── 166f4789877e1a561bdfa2a4c71aab8c11f085
├── [c0]
└── d4787f8625c06984c05f9e26af68860057ba5a
├── [c2]
└── 59d07b508771909537c572008bb6cbfaa516b2
├── [c5]
├── b3bb93a39a392259a0f2df31df81db1fcbae5a
└── c6ca2ce76074c12c083b3b2a31b55e6d2da8b0
├── [c6]
├── 85dff12148fe722441045281d207f071f37f98
└── c12760b55bb72e8836f15f335935c80f4092d5
├── [c7]
└── 18be3383088e281c49ed4febcd2003b73cd2c5
├── [c9]
└── c1964f29e9d0d8a8e8fe8aa91e5e2c2eb4c71b
├── [ca]
└── 827829d7c9389cb781d1bdb5838475eede39dd
├── [cb]
└── 7e25e53d5aa0d6328eeed68d80ac33e62f4dfd
├── [cd]
└── 5662750b0966a24e557ae31c1b4ab020d89720
├── [ce]
├── 2568a368dd294f8f09f576ae195b44dee6da0c
└── 2e886bb048f3d193286eb2d5c7e454bd35716f
├── [d1]
└── 8feb3d8a7d22f310b7b6806e2ae5c70dd7ba25
├── [d2]
└── e29fbfc8755ecfedd338fc50ea9745b206c258
├── [d4]
├── 2a8c537d8333797a0820085e3fb735954b63fa
└── adaf5048ab38a5b890a0b83e17121f73674ea2
├── [d5]
└── a0c155fc09e8349ef38ab7db8d9b8964ad03d7
├── [d7]
└── 94cbe519fcb99c88911b256045a6e14ceda813
├── [da]
└── 17966db1002866f775eab64eda611c0a4501db
├── [dc]
├── 5d214b91a477d5f6309cb8d0508ec4ed211872
├── 739c359f9e0b8395faa2dbb6348b7e821938fe
└── a0914d53d63027c09c93d5fb8a415576ebb557
├── [e0]
└── 8d5af59247dadefeadf79f581fcbe04c51a18a
├── [e1]
└── af81db9c31ef6e0eda47ab9093c9eeaae92e95
├── [e5]
└── b708c83af7172699b6ec8b53f4438fa974cbab
├── [e6]
└── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
├── [e7]
└── 7bb9e2f2884020f3aae541a0d5d525d54ae714
├── [e9]
└── 53d0e4156aafa296c889996e72fe723e8c99a7
├── [ea]
└── 8c4bf7f35f6f77f75d92ad8ce8349f6e81ddba
├── [eb]
└── e8c51e5c9736bd34bebedac8e96af9f85c7006
├── [ec]
└── 34a596371b113f44db2fe23d09a88f186cb7e2
├── [ed]
└── 24086efd9b8d3405d2c24c6d3ff6f769483347
├── [ee]
└── 73f02bba80a95380c020f5daa30bfe23d0a126
├── [f6]
└── fd0e7ee21f57654be66ece54f65ebf4a283729
├── [fa]
├── 8486724cbf0809f4d2739118d05db2601e766e
└── e2fdc70bd7f1c971d48079db50b5a4fbe8124b
├── [fc]
├── 35685f525088e3e1bf3c2d68717bd0fa4d75ef
├── ae2bc7849c95a655c4fd130bb33379a3546c3e
└── d1e5b3f02f66da85f5eaa0fecba962ce47afcb
├── [info]
└── [pack]
└── [refs]
├── [heads]
├── [remotes]
└── [origin]
└── [tags]
.gitignore
Cargo.lock
Cargo.toml
Readme.md
example.md
[src]
├── grammar.pest
├── lib.rs
[tests]
└── tests.rs
--- File Contents ---
--- File: .git/COMMIT_EDITMSG ---
Add tests
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch main
# Your branch is ahead of 'origin/main' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# modified: tests/tests.rs
#
# Changes not staged for commit:
# modified: Readme.md
#
--- File: .git/FETCH_HEAD ---
a4fcbdd72f6683466888fd65093d556a64175753 branch 'main' of https://github.com/mverbytska/my_parser_Verbytska
--- File: .git/HEAD ---
ref: refs/heads/main
--- File: .git/ORIG_HEAD ---
a4fcbdd72f6683466888fd65093d556a64175753
--- File: .git/config ---
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/mverbytska/my_parser_Verbytska
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "main"]
remote = origin
merge = refs/heads/main
--- File: .git/description ---
Unnamed repository; edit this file 'description' to name the repository.
--- File: .git/hooks/applypatch-msg.sample ---
#!/bin/sh
#
# An example hook script to check the commit log message taken by
# applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit. The hook is
# allowed to edit the commit message file.
#
# To enable this hook, rename this file to "applypatch-msg".
. git-sh-setup
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}
:
--- File: .git/hooks/commit-msg.sample ---
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
--- File: .git/hooks/fsmonitor-watchman.sample ---
#!/usr/bin/perl
use strict;
use warnings;
use IPC::Open2;
# An example hook script to integrate Watchman
# (https://facebook.github.io/watchman/) with git to speed up detecting
# new and modified files.
#
# The hook is passed a version (currently 2) and last update token
# formatted as a string and outputs to stdout a new update token and
# all files that have been modified since the update token. Paths must
# be relative to the root of the working tree and separated by a single NUL.
#
# To enable this hook, rename this file to "query-watchman" and set
# 'git config core.fsmonitor .git/hooks/query-watchman'
#
my ($version, $last_update_token) = @ARGV;
# Uncomment for debugging
# print STDERR "$0 $version $last_update_token\n";
# Check the hook interface version
if ($version ne 2) {
die "Unsupported query-fsmonitor hook version '$version'.\n" .
"Falling back to scanning...\n";
}
my $git_work_tree = get_working_dir();
my $retry = 1;
my $json_pkg;
eval {
require JSON::XS;
$json_pkg = "JSON::XS";
1;
} or do {
require JSON::PP;
$json_pkg = "JSON::PP";
};
launch_watchman();
sub launch_watchman {
my $o = watchman_query();
if (is_work_tree_watched($o)) {
output_result($o->{clock}, @{$o->{files}});
}
}
sub output_result {
my ($clockid, @files) = @_;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# binmode $fh, ":utf8";
# print $fh "$clockid\n@files\n";
# close $fh;
binmode STDOUT, ":utf8";
print $clockid;
print "\0";
local $, = "\0";
print @files;
}
sub watchman_clock {
my $response = qx/watchman clock "$git_work_tree"/;
die "Failed to get clock id on '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
return $json_pkg->new->utf8->decode($response);
}
sub watchman_query {
my $pid = open2(\*CHLD_OUT, \*CHLD_IN, 'watchman -j --no-pretty')
or die "open2() failed: $!\n" .
"Falling back to scanning...\n";
# In the query expression below we're asking for names of files that
# changed since $last_update_token but not from the .git folder.
#
# To accomplish this, we're using the "since" generator to use the
# recency index to select candidate nodes and "fields" to limit the
# output to file names only. Then we're using the "expression" term to
# further constrain the results.
my $last_update_line = "";
if (substr($last_update_token, 0, 1) eq "c") {
$last_update_token = "\"$last_update_token\"";
$last_update_line = qq[\n"since": $last_update_token,];
}
my $query = <<" END";
["query", "$git_work_tree", {$last_update_line
"fields": ["name"],
"expression": ["not", ["dirname", ".git"]]
}]
END
# Uncomment for debugging the watchman query
# open (my $fh, ">", ".git/watchman-query.json");
# print $fh $query;
# close $fh;
print CHLD_IN $query;
close CHLD_IN;
my $response = do {local $/; <CHLD_OUT>};
# Uncomment for debugging the watch response
# open ($fh, ">", ".git/watchman-response.json");
# print $fh $response;
# close $fh;
die "Watchman: command returned no output.\n" .
"Falling back to scanning...\n" if $response eq "";
die "Watchman: command returned invalid output: $response\n" .
"Falling back to scanning...\n" unless $response =~ /^\{/;
return $json_pkg->new->utf8->decode($response);
}
sub is_work_tree_watched {
my ($output) = @_;
my $error = $output->{error};
if ($retry > 0 and $error and $error =~ m/unable to resolve root .* directory (.*) is not watched/) {
$retry--;
my $response = qx/watchman watch "$git_work_tree"/;
die "Failed to make watchman watch '$git_work_tree'.\n" .
"Falling back to scanning...\n" if $? != 0;
$output = $json_pkg->new->utf8->decode($response);
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
# Uncomment for debugging watchman output
# open (my $fh, ">", ".git/watchman-output.out");
# close $fh;
# Watchman will always return all files on the first query so
# return the fast "everything is dirty" flag to git and do the
# Watchman query just to get it over with now so we won't pay
# the cost in git to look up each individual file.
my $o = watchman_clock();
$error = $output->{error};
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
output_result($o->{clock}, ("/"));
$last_update_token = $o->{clock};
eval { launch_watchman() };
return 0;
}
die "Watchman: $error.\n" .
"Falling back to scanning...\n" if $error;
return 1;
}
sub get_working_dir {
my $working_dir;
if ($^O =~ 'msys' || $^O =~ 'cygwin') {
$working_dir = Win32::GetCwd();
$working_dir =~ tr/\\/\//;
} else {
require Cwd;
$working_dir = Cwd::cwd();
}
return $working_dir;
}
--- File: .git/hooks/post-update.sample ---
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
exec git update-server-info
--- File: .git/hooks/pre-applypatch.sample ---
#!/bin/sh
#
# An example hook script to verify what is about to be committed
# by applypatch from an e-mail message.
#
# The hook should exit with non-zero status after issuing an
# appropriate message if it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-applypatch".
. git-sh-setup
precommit="$(git rev-parse --git-path hooks/pre-commit)"
test -x "$precommit" && exec "$precommit" ${1+"$@"}
:
--- File: .git/hooks/pre-commit.sample ---
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=$(git hash-object -t tree /dev/null)
fi
# If you want to allow non-ASCII filenames set this variable to true.
allownonascii=$(git config --type=bool hooks.allownonascii)
# Redirect output to stderr.
exec 1>&2
# Cross platform projects tend to avoid non-ASCII filenames; prevent
# them from being added to the repository. We exploit the fact that the
# printable range starts at the space character and ends with tilde.
if [ "$allownonascii" != "true" ] &&
# Note that the use of brackets around a tr range is ok here, (it's
# even required, for portability to Solaris 10's /usr/bin/tr), since
# the square bracket bytes happen to fall in the designated range.
test $(git diff --cached --name-only --diff-filter=A -z $against |
LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0
then
cat <<\EOF
Error: Attempt to add a non-ASCII file name.
This can cause problems if you want to work with people on other platforms.
To be portable it is advisable to rename the file.
If you know what you are doing you can disable this check using:
git config hooks.allownonascii true
EOF
exit 1
fi
# If there are whitespace errors, print the offending file names and fail.
exec git diff-index --check --cached $against --
--- File: .git/hooks/pre-merge-commit.sample ---
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git merge" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message to
# stderr if it wants to stop the merge commit.
#
# To enable this hook, rename this file to "pre-merge-commit".
. git-sh-setup
test -x "$GIT_DIR/hooks/pre-commit" &&
exec "$GIT_DIR/hooks/pre-commit"
:
--- File: .git/hooks/pre-push.sample ---
#!/bin/sh
# An example hook script to verify what is about to be pushed. Called by "git
# push" after it has checked the remote status, but before anything has been
# pushed. If this script exits with a non-zero status nothing will be pushed.
#
# This hook is called with the following parameters:
#
# $1 -- Name of the remote to which the push is being done
# $2 -- URL to which the push is being done
#
# If pushing without using a named remote those arguments will be equal.
#
# Information about the commits which are being pushed is supplied as lines to
# the standard input in the form:
#
# <local ref> <local oid> <remote ref> <remote oid>
#
# This sample shows how to prevent push of commits where the log message starts
# with "WIP" (work in progress).
remote="$1"
url="$2"
zero=$(git hash-object --stdin </dev/null | tr '[0-9a-f]' '0')
while read local_ref local_oid remote_ref remote_oid
do
if test "$local_oid" = "$zero"
then
# Handle delete
:
else
if test "$remote_oid" = "$zero"
then
# New branch, examine all commits
range="$local_oid"
else
# Update to existing branch, examine new commits
range="$remote_oid..$local_oid"
fi
# Check for WIP commit
commit=$(git rev-list -n 1 --grep '^WIP' "$range")
if test -n "$commit"
then
echo >&2 "Found WIP commit in $local_ref, not pushing"
exit 1
fi
fi
done
exit 0
--- File: .git/hooks/pre-rebase.sample ---
#!/bin/sh
#
# Copyright (c) 2006, 2008 Junio C Hamano
#
# The "pre-rebase" hook is run just before "git rebase" starts doing
# its job, and can prevent the command from running by exiting with
# non-zero status.
#
# The hook is called with the following parameters:
#
# $1 -- the upstream the series was forked from.
# $2 -- the branch being rebased (or empty when rebasing the current branch).
#
# This sample shows how to prevent topic branches that are already
# merged to 'next' branch from getting rebased, because allowing it
# would result in rebasing already published history.
publish=next
basebranch="$1"
if test "$#" = 2
then
topic="refs/heads/$2"
else
topic=`git symbolic-ref HEAD` ||
exit 0 ;# we do not interrupt rebasing detached HEAD
fi
case "$topic" in
refs/heads/??/*)
;;
*)
exit 0 ;# we do not interrupt others.
;;
esac
# Now we are dealing with a topic branch being rebased
# on top of master. Is it OK to rebase it?
# Does the topic really exist?
git show-ref -q "$topic" || {
echo >&2 "No such branch $topic"
exit 1
}
# Is topic fully merged to master?
not_in_master=`git rev-list --pretty=oneline ^master "$topic"`
if test -z "$not_in_master"
then
echo >&2 "$topic is fully merged to master; better remove it."
exit 1 ;# we could allow it, but there is no point.
fi
# Is topic ever merged to next? If so you should not be rebasing it.
only_next_1=`git rev-list ^master "^$topic" ${publish} | sort`
only_next_2=`git rev-list ^master ${publish} | sort`
if test "$only_next_1" = "$only_next_2"
then
not_in_topic=`git rev-list "^$topic" master`
if test -z "$not_in_topic"
then
echo >&2 "$topic is already up to date with master"
exit 1 ;# we could allow it, but there is no point.
else
exit 0
fi
else
not_in_next=`git rev-list --pretty=oneline ^${publish} "$topic"`
/usr/bin/perl -e '
my $topic = $ARGV[0];
my $msg = "* $topic has commits already merged to public branch:\n";
my (%not_in_next) = map {
/^([0-9a-f]+) /;
($1 => 1);
} split(/\n/, $ARGV[1]);
for my $elem (map {
/^([0-9a-f]+) (.*)$/;
[$1 => $2];
} split(/\n/, $ARGV[2])) {
if (!exists $not_in_next{$elem->[0]}) {
if ($msg) {
print STDERR $msg;
undef $msg;
}
print STDERR " $elem->[1]\n";
}
}
' "$topic" "$not_in_next" "$not_in_master"
exit 1
fi
<<\DOC_END
This sample hook safeguards topic branches that have been
published from being rewound.
The workflow assumed here is:
* Once a topic branch forks from "master", "master" is never
merged into it again (either directly or indirectly).
* Once a topic branch is fully cooked and merged into "master",
it is deleted. If you need to build on top of it to correct
earlier mistakes, a new topic branch is created by forking at
the tip of the "master". This is not strictly necessary, but
it makes it easier to keep your history simple.
* Whenever you need to test or publish your changes to topic
branches, merge them into "next" branch.
The script, being an example, hardcodes the publish branch name
to be "next", but it is trivial to make it configurable via
$GIT_DIR/config mechanism.
With this workflow, you would want to know:
(1) ... if a topic branch has ever been merged to "next". Young
topic branches can have stupid mistakes you would rather
clean up before publishing, and things that have not been
merged into other branches can be easily rebased without
affecting other people. But once it is published, you would
not want to rewind it.
(2) ... if a topic branch has been fully merged to "master".
Then you can delete it. More importantly, you should not
build on top of it -- other people may already want to
change things related to the topic as patches against your
"master", so if you need further changes, it is better to
fork the topic (perhaps with the same name) afresh from the
tip of "master".
Let's look at this example:
o---o---o---o---o---o---o---o---o---o "next"
/ / / /
/ a---a---b A / /
/ / / /
/ / c---c---c---c B /
/ / / \ /
/ / / b---b C \ /
/ / / / \ /
---o---o---o---o---o---o---o---o---o---o---o "master"
A, B and C are topic branches.
* A has one fix since it was merged up to "next".
* B has finished. It has been fully merged up to "master" and "next",
and is ready to be deleted.
* C has not merged to "next" at all.
We would want to allow C to be rebased, refuse A, and encourage
B to be deleted.
To compute (1):
git rev-list ^master ^topic next
git rev-list ^master next
if these match, topic has not merged in next at all.
To compute (2):
git rev-list master..topic
if this is empty, it is fully merged to "master".
DOC_END
--- File: .git/hooks/pre-receive.sample ---
#!/bin/sh
#
# An example hook script to make use of push options.
# The example simply echoes all push options that start with 'echoback='
# and rejects all pushes when the "reject" push option is used.
#
# To enable this hook, rename this file to "pre-receive".
if test -n "$GIT_PUSH_OPTION_COUNT"
then
i=0
while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"
do
eval "value=\$GIT_PUSH_OPTION_$i"
case "$value" in
echoback=*)
echo "echo from the pre-receive-hook: ${value#*=}" >&2
;;
reject)
exit 1
esac
i=$((i + 1))
done
fi
--- File: .git/hooks/prepare-commit-msg.sample ---
#!/bin/sh
#
# An example hook script to prepare the commit log message.
# Called by "git commit" with the name of the file that has the
# commit message, followed by the description of the commit
# message's source. The hook's purpose is to edit the commit
# message file. If the hook fails with a non-zero status,
# the commit is aborted.
#
# To enable this hook, rename this file to "prepare-commit-msg".
# This hook includes three examples. The first one removes the
# "# Please enter the commit message..." help message.
#
# The second includes the output of "git diff --name-status -r"
# into the message, just before the "git status" output. It is
# commented because it doesn't cope with --amend or with squashed
# commits.
#
# The third example adds a Signed-off-by line to the message, that can
# still be edited. This is rarely a good idea.
COMMIT_MSG_FILE=$1
COMMIT_SOURCE=$2
SHA1=$3
/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
# case "$COMMIT_SOURCE,$SHA1" in
# ,|template,)
# /usr/bin/perl -i.bak -pe '
# print "\n" . `git diff --cached --name-status -r`
# if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;;
# *) ;;
# esac
# SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE"
# if test -z "$COMMIT_SOURCE"
# then
# /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
# fi
--- File: .git/hooks/push-to-checkout.sample ---
#!/bin/sh
# An example hook script to update a checked-out tree on a git push.
#
# This hook is invoked by git-receive-pack(1) when it reacts to git
# push and updates reference(s) in its repository, and when the push
# tries to update the branch that is currently checked out and the
# receive.denyCurrentBranch configuration variable is set to
# updateInstead.
#
# By default, such a push is refused if the working tree and the index
# of the remote repository has any difference from the currently
# checked out commit; when both the working tree and the index match
# the current commit, they are updated to match the newly pushed tip
# of the branch. This hook is to be used to override the default
# behaviour; however the code below reimplements the default behaviour
# as a starting point for convenient modification.
#
# The hook receives the commit with which the tip of the current
# branch is going to be updated:
commit=$1
# It can exit with a non-zero status to refuse the push (when it does
# so, it must not modify the index or the working tree).
die () {
echo >&2 "$*"
exit 1
}